java.lang.Object
g0701_0800.s0790_domino_and_tromino_tiling.Solution

public class Solution extends Object
790 - Domino and Tromino Tiling.<p>Medium</p> <p>You have two types of tiles: a <code>2 x 1</code> domino shape and a tromino shape. You may rotate these shapes.</p> <p><img src="https://assets.leetcode.com/uploads/2021/07/15/lc-domino.jpg" alt="" /></p> <p>Given an integer n, return <em>the number of ways to tile an</em> <code>2 x n</code> <em>board</em>. Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p> <p>In a tiling, every square must be covered by a tile. Two tilings are different if and only if there are two 4-directionally adjacent cells on the board such that exactly one of the tilings has both squares occupied by a tile.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/07/15/lc-domino1.jpg" alt="" /></p> <p><strong>Input:</strong> n = 3</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> The five different ways are show above.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 1</p> <p><strong>Output:</strong> 1</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 1000</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • numTilings

      public int numTilings(int n)