The Domino and Tromino Tiling coding problem asks you to find the number of ways to tile a 2 x n board using two types of tiles: 2x1 dominos and L-shaped trominos. The tiles can be rotated. Since the number of ways can be very large, you need to return the answer modulo 10^9 + 7. This is a more complex version of the standard Fibonacci tiling problem.
Companies like Google and Meta ask the Domino and Tromino Tiling interview question to evaluate a candidate's mastery of dynamic programming interview pattern. It requires identifying multiple states (e.g., a fully filled column vs. a partially filled column) and deriving the transitions between them. It tests your ability to handle complex recurrence relations and optimize them for space.
This is a Dynamic Programming problem. We define states based on the configuration of the board at width i.
dp[i][0]: The number of ways to completely fill a 2x(i) board.dp[i][1]: The number of ways to fill a 2x(i) board with one extra square in the top row of column i+1.dp[i][2]: The number of ways to fill a 2x(i) board with one extra square in the bottom row of column i+1.
By symmetry, dp[i][1] and dp[i][2] are often equal. The recurrence involves combining these states using various tile placements.For n = 3:
n=3 is 5.
As n increases, the interdependencies between "completely filled" and "partially filled" states grow, leading to the recursive formula.n=1 or n=2, which cascades into wrong answers for all subsequent values.When solving tiling problems, draw the possible ways to fill the "last" column. This visual approach helps identify all possible transitions from previous states (i-1, i-2, etc.) and ensures no configurations are missed.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Ways to Express an Integer as Sum of Powers | Medium | Solve | |
| Knight Dialer | Medium | Solve | |
| Number of Dice Rolls With Target Sum | Medium | Solve | |
| Count Ways To Build Good Strings | Medium | Solve | |
| Count Number of Ways to Place Houses | Medium | Solve |