Paint House
A medium-tier problem at 64% community acceptance, tagged with Array, Dynamic Programming. Reported in interviews at Navan and 4 others.
Paint House is a dynamic programming problem that shows up in assessments at Google, LinkedIn, and Citadel. The setup is simple: you have n houses in a row, each needs painting in one of three colors, and adjacent houses can't share a color. Each color costs different amounts per house. The trap is thinking you can greedily pick the cheapest color at each house. You can't. This is a classic DP optimization that catches unprepared candidates hard. With a 64% acceptance rate, it's not the hardest Medium, but the greedy instinct kills most first attempts. If this problem hits your live assessment and the greedy approach tangles you up, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Paint House"
Paint House 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. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe trick is to build up the minimum cost to paint each house, tracking the cost state for each possible color choice. At house i, the cost to paint it color j is the house's cost for color j plus the minimum of painting the previous house either of the other two colors. This creates a 2D DP table where dp[i][j] represents the total cost to paint houses 0 through i with house i painted color j. Most candidates miss this and either write a recursive brute force that times out or try to optimize with greedy logic that produces wrong answers. The pattern is tight: three colors, recurrence on previous house's best non-matching colors, bottom-up fill. Space can be optimized to O(1) by tracking only the previous row. If you haven't drilled this pattern before, Array and Dynamic Programming aren't always obvious bedfellows at first glance, and the state definition is where the confusion lives. StealthCoder handles the DP table setup and recurrence instantly if you hit a wall during the assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Paint House 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. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Paint House interview FAQ
Is Paint House still asked at top companies?+
Yes. Google, LinkedIn, and Citadel are all in the reported asker list. It's a reliable Medium-difficulty pick for assessments testing DP fundamentals. It's not as common as array problems, but it's recent enough and popular enough that you shouldn't skip it.
What's the most common mistake on this problem?+
Greedy thinking. Candidates pick the cheapest color for each house without considering downstream cost impact. The second mistake is forgetting to track which color was used at the previous house, so the recurrence breaks. Both kill you fast.
Do I need a 2D DP table or can I optimize space?+
A 2D table is clearer and passes easily. Space optimization to O(1) is nice but not required for the 60% of candidates who solve it. Focus on correctness and clarity first. If you're solid on the core DP logic, space optimization is a polish move.
How does this relate to the Array and DP topics?+
The array is the input: houses and their color costs. DP is the solve method: you build up solutions from house 0 to n-1, each state depending on prior states. It's a textbook DP pattern where the array structure informs the recurrence relation.
Is there a pattern I can reuse on other house or coloring problems?+
Absolutely. The DP state pattern here (track index and choice, recur on valid prior choices) applies to all constrained coloring and assignment problems. Once you nail Paint House, similar problems on graph coloring or resource assignment become recognizable.
Want the actual problem statement? View "Paint House" on LeetCode →