Algorithm: Leetcode Contest 414
3282. Reach End of Array with Max Score
Solution
class Solution {
public long findMaximumScore(List<Integer> nums) {
long res = 0, curMax = 0;
for(int i: nums) {
res += curMax;
curMax = Math.max(i, curMax);
}
return res;
}
}
Retro
when it comes to array problem, greedy is always a good direction…