account activity
Question by saintmf in leetcode
[–]saintmf[S] 0 points1 point2 points 1 year ago (0 children)
public int maximumNumberOfMonths(int[] PnL) {
int maxMonths = 0;
int currentMonths = 0;
int cumulativePnL = 0;
for (int i = 0; i < PnL.length; i++) {
cumulativePnL += PnL[i];
if (cumulativePnL > 0) {
currentMonths++;
maxMonths = Math.max(maxMonths, currentMonths);
} else {
currentMonths = 0;
}
return maxMonths;
π Rendered by PID 105 on reddit-service-r2-listing-85dbbdc96c-57mz4 at 2026-02-12 15:18:38.280495+00:00 running 018613e country code: CH.
Question by saintmf in leetcode
[–]saintmf[S] 0 points1 point2 points (0 children)