Count Teams
Learn this problemProblem statement
FC Codelona is trying to assemble a team from a roster of available players. They have a minimum number of players they want to sign, and each player needs to have a skill rating within a certain range.
Given a list of players' skill levels with desired upper and lower bounds, determine how many teams can be created from the list.
Function
countTeams(skills: int[], minPlayers: int, minLevel: int, maxLevel: int) → int
Complete the function countTeams in the editor.
countTeams has the following parameters:
- 1.
int[] skills: an array of integers representing the skill levels of players - 2.
int minPlayers: the minimum number of players required to form a team - 3.
int minLevel: the minimum skill level required for a player to be eligible - 4.
int maxLevel: the maximum skill level required for a player to be eligible
Returns
int: the number of ways to form a team that meets the criteria
Examples
Example 1
skills = [12, 4, 6, 13, 5, 10]minPlayers = 3minLevel = 4maxLevel = 10return = 5The list includes players with skill levels [12, 4, 6, 13, 5, 10].
They want to hire at least 3 players with skill levels between 4 and 10, inclusive.
Four of the players with the following skill levels {4, 6, 5, 10} meet the criteria.
There are 5 ways to form a team of at least 3 players: {4, 5, 6}, {4, 6, 10}, {4, 5, 10}, {5, 6, 10}, and {4, 5, 6, 10}.
Return 5.
Constraints
🍇🍇More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026