Another Trip to the Hospital, more free time to research code!

#Remove Palindrome Subsequences(JAVA)
class Solution {
public int removePalindromeSub(String s) {
String rev = new StringBuilder(s).reverse().toString();
if(rev.equals(s)){
return 1;
}
return 2;
}
}
#Min Value for Positive(JAVA)
class Solution {
public int minStartValue(int[] nums) {
int min = 0;
int sum = 0;

for(int num: nums) {
sum += num;
min = Math.min(min, sum);
}

return 1 - min;
}
}
class Solution {
public int countBalls(int lowLimit, int highLimit) {
Map<Integer, Integer> map = new HashMap<>();
int res = 0;
for (int i = lowLimit; i<= highLimit; i++) {
int d = digitSum(i);
map.put(d, map.getOrDefault(d, 0) + 1);
res = Math.max(res, map.get(d));
}
return res;
}

public int digitSum(int num) {
int sum = 0;
while (num != 0) {
sum += (num % 10);
num /= 10;
}
return sum;
}
}
class Solution {
public int[] runningSum(int[] nums) {
for (int i = 1; i < nums.length; i++) {
nums[i] = nums[i] + nums[i - 1];
}
return nums;
}
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Watch Out for SaaS Updates with Aid of UI Automation

Return of the Commute, JavaScript Tricks, & More… — Intertech

High Availability & Fault Tolerance for Monitoring Stack

Alogritham

Business Continuity is More Than Backup and Restore

Image of arrows pointing in different directions.

Faulty logic

Finding The Time To Write Software Documentation In A Busy Startup

My Nimble SaaS Stack

Lego bricks

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Parker Williamson

Parker Williamson

More from Medium

Seven Years Too Late It was a creature unbeknownst to my seven-year-old self, delicately posing in…

Brutal Consistency and the Path of Everyday Resistance

Ambulance (2022) — A Michael Bay Affirmative Statement

Gender Discrimination: How Women are Often Ignored in Medical Situations