Get Number of Teams
A product manager at Amazon wants to choose a two-member team for a project.
There are n employees to choose from where the i-th employee has a skill, skill[i].
The project needs a total skill between min_skill and max_skill, both inclusive.
Given the array skill and two integers min_skill and max_skill, find the number of pairs of employees whose sum of skills is between min_skill and max_skill, both inclusive.
Complete the function getNumTeams in the editor below.
getNumTeams takes the following arguments:
int skill[n]: the skills of the employeesint min_skill: the minimum total skillint max_skill: the maximum total skill
Returns
long int: the number of pairs of employees with the sum of skills in the given range
1Example 1
Skill 1 | Skill 2 | Skill Sum
2 | 3 | 5
2 | 4 | 6
2 | 5 | 7
3 | 4 | 7
Thus there are 4 possible pairs of employees.
Constraints
Limits and guarantees your solution can rely on.
1≤n≤10^51≤skill[i]≤n0≤min_skill≤max_skill≤10^5