Skip to content

790. Domino and Tromino Tiling #1646

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to determine the number of ways to tile a 2xN board using dominoes and trominoes. The solution involves dynamic programming to efficiently compute the number of valid tilings.

Approach

The key insight is to recognize the recurrence relation that captures the number of ways to tile the board up to a given length. The recurrence relation is derived based on the different ways tiles can be added to extend the tiling from smaller boards to larger ones. The recurrence relation is:

  • dp[n] = 2 * dp[n-1] + dp[n-3]

This relation accounts for:

  1. Adding a vertical domino to a tiling of length n-1.
  2. Adding two horizontal dominoes to a tiling of length n-2.
  3. Adding trominoes in configurations th…

Replies: 1 comment 2 replies

Comment options

mah-shamim
May 5, 2025
Maintainer Author

You must be logged in to vote
2 replies
@topugit
Comment options

topugit May 5, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim May 5, 2025
Maintainer Author

Answer selected by topugit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants