Skip to content

Commit

Permalink
我的解法
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Sep 28, 2018
1 parent ea6556c commit 94738fd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lc485. Max Consecutive Ones.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution:
def findMaxConsecutiveOnes(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
res = 0
ress = []
for x in nums:
if x == 1:
res += 1
else:
ress.append(res)
res = 0
ress.append(res)
return max(ress)


nums = [1, 1, 0, 1, 1, 1]
s = Solution()
print(s.findMaxConsecutiveOnes(nums))

0 comments on commit 94738fd

Please sign in to comment.