Skip to content

Commit cb5bc8a

Browse files
committedSep 25, 2019
update: cleanup and comments
1 parent 59a73b1 commit cb5bc8a

File tree

1 file changed

+8
-2
lines changed
  • src/_Problems_/max-consecutive-1s

1 file changed

+8
-2
lines changed
 

‎src/_Problems_/max-consecutive-1s/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* Find the length of maximum consecutive 1s in an array of o & 1
3+
* Input: [1, 0, 1, 1, 0] O/P - 2
4+
* Input: [0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1] O/P - 4
5+
*
6+
* Solved in O(n)
7+
*/
8+
19
function findMaxConsecutive1s(arr) {
210
let count = 0;
311
let max = 0;
@@ -17,5 +25,3 @@ function findMaxConsecutive1s(arr) {
1725
}
1826
return max;
1927
}
20-
21-
console.log(findMaxConsecutive1s([1, 1, 0, 1]));

0 commit comments

Comments
 (0)