Count Valid Teams
Problem statement
You are given an integer array skills, where each value is one player's skill level. A player is eligible when their skill is between lowerBound and upperBound, inclusive.
A team is any subset of eligible players containing at least minPlayers players. Players are distinct even when they have equal skill values.
Return the exact number of valid teams. If fewer than minPlayers players are eligible, return 0.
Function
countValidTeams(skills: int[], minPlayers: int, lowerBound: int, upperBound: int) → longExamples
Example 1
skills = [1,2,3]minPlayers = 2lowerBound = 1upperBound = 3return = 4All three players are eligible. There are three two-player teams and one three-player team.
Example 2
skills = [4,8,5,6]minPlayers = 2lowerBound = 7upperBound = 8return = 0Only the player with skill 8 is eligible, so no team can contain two players.
Example 3
skills = [1,2,3,4]minPlayers = 1lowerBound = 2upperBound = 3return = 3Two players are eligible. Their two singleton teams and the team containing both are valid.
Constraints
1 <= skills.length <= 60.-10^9 <= skills[i] <= 10^9.1 <= minPlayers <= skills.length.-10^9 <= lowerBound <= upperBound <= 10^9.