解法1
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
str_ = ''
for item in nums:
str_ += str(item)
li = str_.split('0')
max = 0
for item in li:
if len(item) > max:
max = len(item)
return max
解法2
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
count = 0
result = 0
for item in nums:
if item == 1:
count += 1
else:
if count > result:
result = count
count = 0
return max(result, count)