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 35dad56 commit 4d32e2dCopy full SHA for 4d32e2d
maxConsecutiveNumber.java
@@ -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