bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 790. Domino and Tromino Tiling

790. Domino and Tromino Tiling

Leetcode Solutions

Dynamic Programming (Bottom-up, space optimization)

  1. Initialize three variables: fCurrent for f(n-1), fPrevious for f(n-2), and pCurrent for p(n-1).
  2. Set base cases: fCurrent = 2, fPrevious = 1, and pCurrent = 1.
  3. Iterate from k = 3 to n, updating fCurrent, fPrevious, and pCurrent using the transition functions.
  4. After the loop, fCurrent will hold the number of ways to fully cover a 2 x n board.
  5. Return fCurrent modulo 10^9 + 7.
UML Thumbnail

Dynamic Programming (Top-down with Memoization)

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...