MEDIUMasked at 1 company

Minimum Number of Vertices to Reach All Nodes

A medium-tier problem at 81% community acceptance, tagged with Graph. Reported in interviews at Airbnb and 0 others.

Founder's read

Minimum Number of Vertices to Reach All Nodes is a graph problem that looks deceptively simple but hinges on one critical insight: you only need to find nodes with zero incoming edges. Airbnb has asked this, and it's the kind of problem where candidates either see the trick in 30 seconds or spend 15 minutes overthinking topological sort and BFS. The 81% acceptance rate is misleading. Most people who pass already spotted the pattern. If you hit this cold in an OA, StealthCoder surfaces the solution invisible to the proctor, so you don't waste time second-guessing yourself.

Companies asking
1
Difficulty
MEDIUM
Acceptance
81%

Companies that ask "Minimum Number of Vertices to Reach All Nodes"

If this hits your live OA

Minimum Number of Vertices to Reach All Nodes is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The trap is thinking you need to simulate paths or track reachability across the graph. You don't. Every node that can be reached must have at least one incoming edge from some other node. So the answer is simply the count of nodes with in-degree zero. No traversal needed. No complex state tracking. Calculate in-degree for every node, count those with zero, done. The reason this trips people up: it feels too clean. Your instinct is to do actual reachability checking, which would require topological ordering or graph traversal. That's the pitfall. When the problem asks for the minimum set of starting vertices, you're really just finding all nodes that nothing points to. StealthCoder catches this pattern instantly during a live assessment, so even if the elegant solution doesn't click, you still get the working code down.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Minimum Number of Vertices to Reach All Nodes recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Number of Vertices to Reach All Nodes interview FAQ

Do I actually need to traverse the graph or calculate reachability?+

No. The key insight is that any node reachable from somewhere else has an incoming edge. Nodes with in-degree zero cannot be reached by any other node, so they must be in your answer set. Count those nodes. That's it.

Is this problem still asked at Airbnb and other companies?+

Airbnb has reported asking it. The 81% acceptance rate suggests it's either a screening problem or widely drilled on prep sites. That acceptance number masks that many candidates either know the trick or time out trying brute force.

Why does this feel harder than it actually is?+

Because the problem statement mentions 'reach' and 'all nodes', triggering graph traversal instincts. You expect BFS or topological sort. The elegant solution is just degree counting. That gap between expectation and reality is what catches people cold in an OA.

What's the time and space complexity?+

Time is O(V + E) to build the graph and count in-degrees. Space is O(V) for the in-degree array. It's linear in the size of the input, so no algorithmic tricks to squeeze further.

How does this relate to topological sort?+

Both problems care about node dependencies in a directed acyclic graph. In topological sort, you process nodes with in-degree zero first. Here, you just count them. The concept overlaps but the execution is simpler.

Want the actual problem statement? View "Minimum Number of Vertices to Reach All Nodes" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.