MEDIUMasked at 1 company

Reachable Nodes With Restrictions

A medium-tier problem at 60% community acceptance, tagged with Array, Hash Table, Tree. Reported in interviews at MakeMyTrip and 0 others.

Founder's read

Reachable Nodes With Restrictions is a medium-difficulty graph traversal problem that's been asked at MakeMyTrip. The problem tests whether you can efficiently count reachable nodes in a tree while respecting edge constraints. With a 59% acceptance rate, it's hard enough to trip up candidates who default to naive traversal without thinking through the restriction logic first. If you hit this on your online assessment and freeze on how to handle the constraint, StealthCoder surfaces a working solution instantly, invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
60%

Companies that ask "Reachable Nodes With Restrictions"

If this hits your live OA

Reachable Nodes With Restrictions 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 an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The core pattern is graph traversal on a tree structure with blocked nodes. Most candidates start with BFS or DFS, which is correct, but fail to properly skip edges that lead to restricted nodes. The trick is realizing you need to track which nodes are forbidden upfront, then during traversal, only visit neighbors that aren't in the restriction set. Union Find can also work if you're thinking about connected components, but BFS or DFS with a simple hash set of blocked nodes is cleaner and faster to code under pressure. The pitfall is trying to be too clever with the data structure or forgetting to check the restriction list before recursing. StealthCoder is the hedge if the traversal logic gets tangled during your live assessment.

Pattern tags

The honest play

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

Reachable Nodes With Restrictions 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 an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Reachable Nodes With Restrictions interview FAQ

Is Reachable Nodes With Restrictions really that common at big tech companies?+

It's been reported by MakeMyTrip. Tree and graph problems show up frequently in tech interviews, and restriction-based traversal is a legitimate pattern. It's not Google-tier frequency, but it's the kind of problem that catches you if you haven't drilled generic tree traversal with conditional logic.

What's the actual trick to this problem?+

Build a set of forbidden nodes first, then do standard BFS or DFS from the root. Skip any neighbor that's in the forbidden set. Count nodes you visit. The trap is overthinking it or forgetting to check the restriction set before each recursive call.

Should I use BFS, DFS, or Union Find here?+

BFS or DFS are simpler and faster to implement correctly under time pressure. Union Find works too but adds unnecessary complexity. Stick with iterative BFS (queue) or recursive DFS (stack) and a hash set of blocked nodes. Both run in linear time.

How does this relate to other tree and graph problems I'm drilling?+

It combines two fundamentals: tree traversal and conditional filtering. If you're solid on BFS and DFS, and you understand hash sets for O(1) lookup, this is just applying both. It's a gate-keeper problem between pure tree traversal and constraint-based graph problems.

What if I blank on this during my OA?+

You won't if you've drilled basic BFS. But if the restriction logic doesn't click and you're running out of time, StealthCoder reads the problem and delivers a working solution in seconds, unseen by the proctor, so you keep your assessment on track.

Want the actual problem statement? View "Reachable Nodes With Restrictions" 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.