标签:mamicode solution leetcode alt else 图片 style code img
题目描述:
提交:O(N)
class Solution: def kLengthApart(self, nums: List[int], k: int) -> bool: c = k for i in nums: if i == 1: if c < k: return False else: c = 0 else: c += 1 return True
leetcode-187周赛-5401-是否所有1都至少相隔k个元素
标签:mamicode solution leetcode alt else 图片 style code img
原文地址:https://www.cnblogs.com/oldby/p/12823333.html