You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Solution {
public int maximumEnergy(int[] energy, int k) {
int l = energy.length;
int[] dp = new int[l];
int result = Integer.MIN_VALUE;for (int i = l - 1; i >= 0; i--) {
dp[i] = energy[i] + (i + k < l ? dp[i + k] : 0);
result = Math.max(result, dp[i]);
}
return result;
}
}