Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of People That Can Be Caught in Tag

Try to solve the Maximum Number of People That Can Be Caught in Tag problem.

Statement

You are given a 00 indexed binary array team and an integer dist. A value of team[i] == 1 indicates that the person at index i is “it”, while a value of team[i] == 0 indicates that the person is not “it”.

A person who is “it” at index i can catch at most one person at index j if team[j] == 0 and ∣i−j∣≤|i - j| \le dist. Each person who is not “it” can be caught by at most one person.

Return the maximum number of people that can be caught.

Constraints:

  • 1≤1 \le team.length ≤105\le 10^5

  • 0≤0 \le team[i] ≤1\le 1

  • 1≤1 \le dist ≤\le team.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of People That Can Be Caught in Tag

Try to solve the Maximum Number of People That Can Be Caught in Tag problem.

Statement

You are given a 00 indexed binary array team and an integer dist. A value of team[i] == 1 indicates that the person at index i is “it”, while a value of team[i] == 0 indicates that the person is not “it”.

A person who is “it” at index i can catch at most one person at index j if team[j] == 0 and ∣i−j∣≤|i - j| \le dist. Each person who is not “it” can be caught by at most one person.

Return the maximum number of people that can be caught.

Constraints:

  • 1≤1 \le team.length ≤105\le 10^5

  • 0≤0 \le team[i] ≤1\le 1

  • 1≤1 \le dist ≤\le team.length