Get Number of Teams

Problem Overview

  • Count distinct two-employee pairs whose skill sums fall within [min_skill, max_skill] inclusive.
  • Input: skill array (n), min_skill, max_skill; Output: long int count; implement getNumTeams.
  • Constraints: 1≤n≤1e5, 1≤skill[i]≤n, 0≤min_skill≤max_skill≤1e5.
  • Context: Product manager forming a two-member team for a project based on total skill.
  • From Amazon interviews; a coding interview problem and common interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: