Counting Towers
Your task is to build a tower of width 2 and height n. You have an unlimited supply of blocks whose width and height are integers. However, no block can have a width strictly greater than 2.
Given n, how many different ways can you build the tower?
Since the answer can be very large, return it modulo 109 + 7.
Example 1:
Input: n = 1
Output: 2
Explanation: We build a tower of width 2 and height 1.
Possible configurations:
- Two separate 1×1 blocks.
- One 1×2 block covering the entire row.
Total possible towers = 2.
Example 2:
Input: n = 3
Output: 34
Explanation: As the height increases, blocks can extend across multiple rows and columns, creating many possible arrangements. The total number of towers of height 3 is 34.
Now Your Turn!
Pick the correct output for the given inputInput : n = 2
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 <= 106