File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * 485. Max Consecutive Ones
3
+ * https://leetcode.com/problems/max-consecutive-ones/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given a binary array nums, return the maximum number of consecutive 1's in the array.
7
+ */
8
+
9
+ /**
10
+ * @param {number[] } nums
11
+ * @return {number }
12
+ */
13
+ var findMaxConsecutiveOnes = function ( nums ) {
14
+ let max = 0 ;
15
+ for ( let i = 0 , count = 0 ; i < nums . length ; i ++ ) {
16
+ count = nums [ i ] ? count + 1 : 0 ;
17
+ max = Math . max ( max , count ) ;
18
+ }
19
+ return max ;
20
+ } ;
Original file line number Diff line number Diff line change 195
195
461|[ Hamming Distance] ( ./0461-hamming-distance.js ) |Easy|
196
196
463|[ Island Perimeter] ( ./0463-island-perimeter.js ) |Medium|
197
197
476|[ Number Complement] ( ./0476-number-complement.js ) |Easy|
198
+ 485|[ Max Consecutive Ones] ( ./0485-max-consecutive-ones.js ) |Easy|
198
199
491|[ Non-decreasing Subsequences] ( ./0491-non-decreasing-subsequences.js ) |Medium|
199
200
492|[ Construct the Rectangle] ( ./0492-construct-the-rectangle.js ) |Easy|
200
201
500|[ Keyboard Row] ( ./0500-keyboard-row.js ) |Easy|
You can’t perform that action at this time.
0 commit comments