WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Wall Street Quant · Puzzles & Problems · question 30 of 155

How many ways are there to tile a 3xn rectangle with 2x1 dominoes?

📕 Buy this interview preparation book: 155 Wall Street Quant questions & answers — PDF + EPUB for $5

This is a classic combinatorial problem, and it can be solved using recurrence relations. Let’s define that T(n) is the number of ways to tile a 3xn rectangle with 2x1 dominoes.

We can analyze the last column to help us come up with the recurrence relation. If we take a 3xn board, the last column can have one of the following configurations: 1. Three horizontal dominoes:

[][][]   [][][]
[_|_][_][_]  |  |  |

After removing these three horizontal dominoes, we are left with a 3x(n-3) board. Thus, in this case, the number of ways to tile the board is T(n-3).

2. One vertical domino and one horizontal domino:

[][]      [][]
 |  |       [_][_]
[_|_]       |  |

After removing these pieces, we are left with a 3x(n-1) board. Thus, in this case, the number of ways to tile the board is T(n-1).

So combining these two possible configurations, we have the following recurrence relation:


T(n) = T(n − 1) + T(n − 3)

Now, let’s set up the base cases:

1. T(0) = 1: There’s only one way to tile a 3x0 board (by not placing any dominoes).

2. T(1) = 0: It’s impossible to cover a 3x1 board with 2x1 dominoes.

3. T(2) = 0: It’s impossible to cover a 3x2 board with 2x1 dominoes.

Using this recurrence relation and base cases, we can calculate T(n) for any positive integer n. Here’s the table of values for T(n) from n=0 to n=10:

n  | T(n)
---------
0  | 1
1  | 0
2  | 0
3  | 1
4  | 0
5  | 1
6  | 1
7  | 1
8  | 2
9  | 2
10 | 3

For example, T(10) = 3, which means there are three ways to tile a 3x10 rectangle with 2x1 dominoes.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Wall Street Quant interview — then scores it.
📞 Practice Wall Street Quant — free 15 min
📕 Buy this interview preparation book: 155 Wall Street Quant questions & answers — PDF + EPUB for $5

All 155 Wall Street Quant questions · All topics