Count Teams
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.
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
1Example 1
The 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
Limits and guarantees your solution can rely on.
๐๐