Number of Ways to Build House of Cards
A medium-tier problem at 62% community acceptance, tagged with Math, Dynamic Programming. Reported in interviews at Airbnb and 0 others.
You're looking at a medium-difficulty problem that Airbnb has asked. Number of Ways to Build House of Cards combines math and dynamic programming in a way that trips up candidates who try to brute-force it. The acceptance rate sits at 62%, which means it's not a gimme but it's not a slayer either. The actual problem requires you to figure out how many valid structures you can build with a given number of cards, which sounds like it should be a simple formula until you start working through the constraints. If this lands in your assessment and you blank on the combinatorial pattern, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Number of Ways to Build House of Cards"
Number of Ways to Build House of Cards 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 Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe trap here is thinking you can just calculate factorials and call it a day. The problem has physical constraints: a house of cards at level k needs a specific number of cards to exist, and you can't skip levels. This is where dynamic programming enters. You build up from smaller houses, tracking how many ways you can place cards at each level, then sum the valid configurations. The math piece involves understanding the structure itself: each level expands, each card arrangement multiplies possibilities, but not all card counts lead to valid houses. Most candidates either miss the constraint entirely and overcount, or they try to enumerate recursively without memoization and timeout. The DP state should track remaining cards and current level, or similar. When you hit this live, the pattern isn't obvious from the problem statement alone. StealthCoder handles the state definition and recurrence relation so you can focus on coding correctly.
Pattern tags
You know the problem.
Make sure you actually pass it.
Number of Ways to Build House of Cards 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 Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Number of Ways to Build House of Cards interview FAQ
Is this really just a math formula or do I need DP?+
Both. You need to understand the mathematical structure of how cards stack (the constraint on cards per level), then use DP to count valid ways to distribute your total cards across levels. Pure formula won't work because not every card count is reachable.
Why is the acceptance rate 62% and not higher?+
Most candidates miss the structural constraint or the need for memoization. They either overcount by ignoring which levels are buildable, or they write an exponential recursion that times out. Knowing the trick cuts your solve time in half.
Has Airbnb stopped asking this?+
Airbnb is the only company reported to ask it in this dataset, so it's not a common problem across the board. But it does appear in Airbnb assessments, so if you're prepping for them, this belongs on your list.
What's the key insight I'm missing?+
The house has levels: level 1 uses 2 cards, level 2 uses 7 more, level 3 uses 12 more, etc. You must build sequentially from bottom up. DP tracks ways to spend exactly k cards up to level i, then transitions to level i+1.
How does this connect to the two topics listed?+
Math gives you the formula for cards needed at each level. Dynamic programming is how you count configurations efficiently without enumerating all of them. Together they solve it in polynomial time.
Want the actual problem statement? View "Number of Ways to Build House of Cards" on LeetCode →