Count Cross-Group Employee Pairs
Company: Snapchat
Role: Backend Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of graph connectivity and component aggregation (often involving disjoint-set concepts) along with combinatorial counting to compute cross-group pairs.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: (5, [[0,1],[0,2],[3,4]])
Expected Output: 6
Explanation: Two groups of sizes 3 and 2 produce 6 pairs.
Input: (4, [])
Expected Output: 6
Explanation: All employees isolated produce C(4,2) pairs.
Input: (3, [[0,1],[1,2]])
Expected Output: 0
Explanation: One group means no cross-group pairs.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.