Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cb5bc8a

Browse files
committed
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‎

Lines changed: 8 additions & 2 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /