1989. Maximum Number of People That Can Be Caught in Tag
Содержание
class Solution:
def catchMaximumAmountofPeople(self, team: List[int], dist: int) -> int:
res = j = 0
n = len(team)
for i, x in enumerate(team):
if x:
while j < n and (team[j] or i - j > dist):
j += 1
if j < n and abs(i - j) <= dist:
res += 1
j += 1
return res