Description
Solutions
Get Number of Teams
🔥 FULLTIME

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 Description

Complete the function getNumTeams in the editor below.

getNumTeams takes the following arguments:

  1. int skill[n]: the skills of the employees
  2. int min_skill: the minimum total skill
  3. int max_skill: the maximum total skill

Returns

long int: the number of pairs of employees with the sum of skills in the given range

Example 1:

Input:  skill = [2, 3, 4, 5], min_skill = 5, max_skill = 7
Output: 4
Explanation:

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:
    • 1≤n≤10^5
    • 1≤skill[i]≤n
    • 0≤min_skill≤max_skill≤10^5
Thumbnail 0
Testcase

Result
Case 1

input:

output: