Identify the Influencer Everyone Follows but Who Follows Nobody
Last updated: November 29, 2026
Quick Overview
Among n members, an influencer is followed by all other n - 1 members and follows none of them. Using only an API follows(a, b), return the influencer's id or -1, making O(n) calls.
0
0
0 solved
Among n members, an influencer is followed by all other n - 1 members and follows none of them. Using only an API follows(a, b), return the influencer's id or -1, making O(n) calls.
The LinkedIn follow graph makes this classic elimination question feel natural, and the API-call budget is the real test. Interviewers check the elimination argument and the verification pass that many candidates forget.
What the Interviewer Expects
- Explains that each follows(a, b) call eliminates one candidate
- Runs a single elimination pass to find one candidate
- Verifies the candidate with a second pass
- Keeps calls at most 3(n - 1)
- Handles the no-influencer case
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Can you reduce calls in the verification pass by reusing elimination results?
- What if follows is an expensive remote call and you can batch requests?
- How would you find all members followed by at least 90% of others?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Members are 0..n-1. follows(a, b) returns True if a follows b. There is at most one influencer (two cannot exist because they would have to follow each other). Return the id or -1....
High-Level Design
Elimination: keep a candidate c, starting at 0. For each i from 1, if follows(c, i), then c follows someone and is out, so set c = i; otherwise i is not followed by c, so i is out. After one pass, e...