Skip to content

Commit 4d32e2d

Browse files
Create maxConsecutiveNumber.java
1 parent 35dad56 commit 4d32e2d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

maxConsecutiveNumber.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int findMaxConsecutiveOnes(int[] nums) {
3+
int count = 0;
4+
int MaxCount = 0;
5+
for(int i=0; i<nums.length; i++){
6+
if(nums[i]==1){
7+
count +=1;
8+
}
9+
else{
10+
MaxCount = Math.max(MaxCount, count);
11+
count =0;
12+
}
13+
}
14+
return Math.max(MaxCount, count);
15+
16+
}
17+
}

0 commit comments

Comments
 (0)