485. 最大连续1的个数
链接:
https://leetcode.cn/problems/max-consecutive-ones/description/
思路:
没啥好说的吧.....基础题目
代码
class Solution: def findMaxConsecutiveOnes(self, nums: List[int]) -> int: res = 0 cur_res = 0 for i in nums: if i == 1: cur_res += 1 res = max(cur_res, res) else: cur_res = 0 return res