相当简单的一道题目,没怎么修改就过了。
#485
#https://leetcode.com/problems/max-consecutive-ones/description/
#2018.4.29
class Solution(object):
def findMaxConsecutiveOnes(self, nums):
lens = len(nums)
maxlen = 0
outs = 0
for num in nums:
if num == 1:
maxlen += 1
else:
if maxlen > outs:
outs = maxlen
maxlen = 0
return max(maxlen,outs)