Rob House
Reported by candidates from Epam's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Epam's Rob House problem hit the assessment pipeline in August 2024, and it's a classic dynamic programming gauntlet disguised as a simple heist scenario. You're given a row of houses, each with some cash, and you can't rob adjacent ones. It sounds straightforward until you realize you need to track state across every decision. StealthCoder will be your safety net if the recurrence relation doesn't click in the moment. The pattern is tight, the edge cases are sneaky, and you'll see this again.
Pattern and pitfall
The trick here is recognizing that you need to decide for each house: rob it or skip it. If you rob house i, you get its value plus the max profit from houses up to i-2. If you skip it, you get the max profit from houses up to i-1. That's your recurrence. Most candidates hardcode a 2D DP table or miss the space optimization to O(1) by keeping only the last two states. The greedy instinct (always rob the biggest house) fails fast. During the live OA, if you blank on the formulation, StealthCoder reads the problem and surfaces the DP pattern so you can code with confidence instead of guessing.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Rob House cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderThis OA pattern shows up on LeetCode as house robber. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Epam's OA.
Epam reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Rob House FAQ
Is this really just the classic House Robber problem or does Epam twist it?+
Typically it's the canonical version, but watch for variants like circular houses or weight constraints. Epam tends to keep core problems clean and test implementation rigor. Assume linear unless told otherwise. If there's a twist, it will be explicit in the problem statement.
Do I need to return the houses robbed or just the max amount?+
Most OAs ask for the max amount only. If they want the actual houses, you track decisions during DP. Check the output format carefully. Epam usually specifies this clearly. Don't assume. Read the examples.
Can I solve this with recursion and memoization instead of bottom-up DP?+
Yes. Memoization is cleaner to write under pressure and avoids table initialization bugs. Define a recursive function that returns max profit from house i onward, memoize it, and call from house 0. Both pass, but memoization is faster to code correctly in 20 minutes.
What's the time and space complexity I should target?+
O(n) time, O(1) space is the gold standard if you only track prev and prev2. O(n) space with a DP array is acceptable and easier to debug. Don't over-optimize early. Get it working, then clean it up if you have time.
Will Epam test with huge arrays or tricky edge cases like a single house?+
Single house, two houses, empty input, and arrays with 10k elements are all fair game. Your base cases matter. Test rob(0) and rob(1) mentally before you submit. Edge cases are where OA mistakes live.