MEDIUMasked at 2 companies

House Robber III

A medium-tier problem at 55% community acceptance, tagged with Dynamic Programming, Tree, Depth-First Search. Reported in interviews at oyo and 1 others.

Founder's read

House Robber III combines tree traversal with dynamic programming in a way that trips up candidates who've only drilled array versions of the problem. You're given a binary tree where each node has a value, and you can't rob two directly connected nodes. OYO and PhonePe ask this. The twist: you have to decide at every node whether robbing it or skipping it gives you the max take. If you freeze on tree DP during the live assessment, StealthCoder surfaces a working solution in seconds, invisible to the proctor. This problem has a 55% acceptance rate, so it's not trivial.

Companies asking
2
Difficulty
MEDIUM
Acceptance
55%

Companies that ask "House Robber III"

If this hits your live OA

House Robber III 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 for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The trap is treating this like a standard tree problem where you just pick the greedy path. You can't. You have to track two states at each node: the max value if you rob this node, and the max value if you don't. Then you combine the child states intelligently. DFS with memoization solves it, but the state design is the crux. Many candidates sketch the tree, see two paths, and start writing a broken greedy solution. The DP twist doesn't land until they realize they need to compute both outcomes from every subtree. When you're live and the pattern doesn't click, StealthCoder's got the state machine mapped out.

Pattern tags

The honest play

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

House Robber III 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 for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

House Robber III interview FAQ

Is House Robber III actually harder than the array version?+

Yes. The array version lets you iterate left to right. Here, you're managing multiple states across a tree structure. The 55% acceptance rate confirms it. The algorithmic jump is real, not a slight variation.

What's the actual trick to House Robber III?+

Define your DP return as a pair or tuple: max value if you rob this node, max value if you don't. Recurse on both children, then combine. The key is that if you rob a node, you can't rob its children. If you don't rob it, you can rob either or both children.

Do OYO and PhonePe ask this in the same interview loop?+

Both companies have asked it. It's a medium-difficulty problem, so it could appear as a second or standalone problem depending on the round. Treat it as a credible live threat.

Can I solve House Robber III without explicitly memoizing?+

Yes, but only if you're comfortable with the tree DP pattern. A single DFS pass with proper state tracking works if you nail the recurrence relation. Most candidates add memoization anyway to be safe.

How does this relate to other Dynamic Programming topics?+

It's the bridge between simple DP and tree DP. You're solving overlapping subproblems on a graph with cycles prevented by the tree structure. It tests whether you can lift DP thinking from linear to non-linear domains.

Want the actual problem statement? View "House Robber III" 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.