Tile an grid with dominoes. How many ways? = number of ways to fill rows completely, with current row having profile . Base: (empty grid, nothing filled yet). Transition: for each mask, try all ways to fill the row.
Answer: (all rows filled, final profile is empty). Time:
Time complexity: .
Space complexity: = .