Counting Tilings

You are given a grid of size: n × m

You must fill the grid using domino tiles of size:

1 × 2  (horizontal)
2 × 1  (vertical)
Your task is to Count the number of ways to tile the grid completely.
Return the answer mod 109 + 7

Example 1:

Input: n = 2, m = 2

Output: 2

Explanation: Two possible tilings

Vertical:
| |
| |

Horizontal:
== 
==

Example 2:

Input: n = 2, m = 3

Output: 3

Explanation : Possible tiling's:

1) all vertical
2) horizontal pair + vertical
3) vertical + horizontal pair

Now Your Turn!

Pick the correct output for the given input

Input: n = 2, m = 4

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 ≤ n ≤ 10
  • 1 ≤ m ≤ 1000

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
int countingTilings(int n, int m) {
// Write your code here
return 0;
}
};
Test Case

Input:

M
N