We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e3cd2dd commit 0570354Copy full SHA for 0570354
src/main/java/g0401_0500/s0485_max_consecutive_ones/Solution.java
@@ -5,13 +5,15 @@
5
public class Solution {
6
public int findMaxConsecutiveOnes(int[] nums) {
7
int maxLen = 0;
8
- for (int i = 0; i < nums.length; i++) {
+ int i = 0;
9
+ while (i < nums.length) {
10
int currentLen = 0;
11
while (i < nums.length && nums[i] == 1) {
12
i++;
13
currentLen++;
14
}
15
maxLen = Math.max(maxLen, currentLen);
16
+ i++;
17
18
return maxLen;
19
0 commit comments