python leetcode 每日打卡之1004

class Solution:
    def longestOnes(self, A: List[int], K: int) -> int:
        left , count = 0 , 0    
        for right in range(len(A)):
            if A[right] == 0:
                count += 1
            if count > K:
                if A[left] == 0:
                    count -= 1
                left += 1
        return right-left+1

 

你可能感兴趣的:(leetcode,python)