Skip to content

Commit a785d21

Browse files
authored
Create Max Consecutive Ones.py
1 parent 3674e24 commit a785d21

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

easy/Max Consecutive Ones.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#485 Max Consecutive Ones
2+
class Solution:
3+
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
4+
ans = 0
5+
summ = 0
6+
7+
for num in nums:
8+
if num == 0:
9+
summ = 0
10+
else:
11+
summ += num
12+
ans = max(ans, summ)
13+
14+
return ans

0 commit comments

Comments
 (0)