Skip to content

Commit d70f709

Browse files
committed
Runtime: 4 ms (Top 25.35%) | Memory: 56.8 MB (Top 44.29%)
1 parent fa9e690 commit d70f709

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Runtime: 4 ms (Top 25.35%) | Memory: 56.8 MB (Top 44.29%)
2+
class Solution {
3+
public int findMaxConsecutiveOnes(int[] nums) {
4+
int max = 0;
5+
int new_max = 0;
6+
for(int i=0;i<nums.length;i++){
7+
if(nums[i]==1)
8+
{
9+
max++;
10+
}
11+
else{
12+
if(max>new_max){
13+
new_max = max;
14+
}
15+
max = 0;
16+
}
17+
}
18+
if(max<new_max)
19+
return new_max;
20+
else
21+
return max;
22+
}
23+
}

0 commit comments

Comments
 (0)