Created
July 24, 2018 03:02
-
-
Save luojiyin1987/84203f27a92b69617fb3d4f37951ff3d to your computer and use it in GitHub Desktop.
Max Consecutive Ones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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