Skip to content

Instantly share code, notes, and snippets.

@luojiyin1987
Created July 24, 2018 03:02
Show Gist options
  • Save luojiyin1987/84203f27a92b69617fb3d4f37951ff3d to your computer and use it in GitHub Desktop.
Save luojiyin1987/84203f27a92b69617fb3d4f37951ff3d to your computer and use it in GitHub Desktop.
Max Consecutive Ones
class Solution:
def findMaxConsecutiveOnes(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
maxNum = 0
count = 0
for num in nums:
if num == 1:
count+=1
else:
maxNum =max(count, maxNum)
count = 0
maxNum = max(count, maxNum)
return maxNum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment