Number of Times Binary String Is Prefix-Aligned LeetCode solution in Java

1
class Solution {
2
public int numTimesAllBlue(int[] flips) {
3
int counter = 0, total = 0, max = Integer.MIN_VALUE;
4
for (int i = 0; i < flips.length; i++) {
5
if (max < flips[i]) max = flips[i];
6
if (++counter == max) total++;
7
}
8
return total;
9
}
10
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0