File tree 2 files changed +20
-1
lines changed 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 126
126
| 475 | [ Heaters] ( https://leetcode.com/problems/heaters ) | Medium | |
127
127
| 476 | [ Number Complement] ( https://leetcode.com/problems/number-complement ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/NumberComplement.java ) |
128
128
| 482 | [ License Key Formatting] ( https://leetcode.com/problems/license-key-formatting ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/LicenseKeyFormatting.java ) |
129
- | 485 | [ Max Consecutive Ones] ( https://leetcode.com/problems/max-consecutive-ones ) | Easy | |
129
+ | 485 | [ Max Consecutive Ones] ( https://leetcode.com/problems/max-consecutive-ones ) | Easy | [ ![ Java ] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/MaxConsecutiveOnes.java ) |
130
130
| 492 | [ Construct the Rectangle] ( https://leetcode.com/problems/construct-the-rectangle ) | Easy | |
131
131
| 496 | [ Next Greater Element I] ( https://leetcode.com/problems/next-greater-element-i ) | Easy | |
132
132
| 500 | [ Keyboard Row] ( https://leetcode.com/problems/keyboard-row ) | Easy | |
Original file line number Diff line number Diff line change
1
+ public class MaxConsecutiveOnes {
2
+ public int findMaxConsecutiveOnes (int [] array ) {
3
+ int maxOnes = 0 , current = 0 ;
4
+ for (int number : array ) {
5
+ if (number == 1 ) {
6
+ current ++;
7
+ maxOnes = Math .max (maxOnes , current );
8
+ } else {
9
+ current = 0 ;
10
+ }
11
+ }
12
+
13
+ return maxOnes ;
14
+ }
15
+
16
+ public static void main (String [] args ) {
17
+
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments