Find a special person using knows(a,b)
Company: HubSpot
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Onsite
Quick Answer: This question evaluates algorithmic reasoning about pairwise relation inference using an oracle-style knows(a, b) API and the ability to minimize API calls, testing skills in graph modeling and asymptotic analysis.
Examples
Input: ([[False, True, True], [False, False, True], [False, False, False]],)
Expected Output: 2
Explanation: Person 2.
Input: ([[False, True], [True, False]],)
Expected Output: -1
Explanation: No special person.
Input: ([[False]],)
Expected Output: 0
Explanation: Single person.
Hints
- Eliminate candidates in one pass, then verify the survivor.