Get Number of Teams
Learn this problemProblem statement
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.
Function
getNumTeams(skill: int[], min_skill: int, max_skill: int) → long
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
Examples
Example 1
skill = [2, 3, 4, 5]min_skill = 5max_skill = 7return = 4Skill 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
1≤n≤10^51≤skill[i]≤n0≤min_skill≤max_skill≤10^5
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026