Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 790 Domino and Tromino Tiling - Problem Statement

LeetCode 790

Tile a 2×n2 \times n board with two tile types: 1×21 \times 2 dominoes (horizontal or vertical) and L-shaped trominoes (each covering 33 cells). Count the number of tilings modulo 109+710^9 + 7, where nn can be up to 10001000. Trominoes add new profile states: you can have one row sticking out one cell further than the other.

This creates profiles you didn't see with dominoes alone. With nn up to 10001000, you need an O(n)O(n) time, O(1)O(1) space solution. Broken profile DP with 22 rows gives you states and formulas that lead to a recurrence.