Problem
Given a binary array nums, return the maximum number of consecutive 1’s in the array.
Algorithm
Just count directly
Code
class Solution:def findMaxConsecutiveOnes(self, nums: List[int]) -> int:maxn, cnts = 0, 0for num in nums:if num:cnts += 1else:if maxn < cnts:maxn = cntscnts = 0if maxn < cnts:maxn = cntsreturn maxn