You are given a board of size 2 × N and an unlimited number of 2 × 1 tiles. Each tile can be placed either vertically or horizontally. Calculate and return the total number of ways to completely tile the board.
Example 1
Input: N = 5
Output: 8
Explanation: For a 2 × 5 board, you can either place one vertical tile and solve for length 4, or place two horizontal tiles and solve for length 3. Combining these possibilities gives 8 total ways.
Example 2
Input: N = 6
Output: 13
Explanation: The number of ways equals the sum of ways for lengths 5 and 4 (8 + 5), resulting in 13 possible tilings.
Example 3
Input: N = 7
Output: 21
Explanation: Similarly, ways for length 7 = ways(6) + ways(5) = 13 + 8 = 21 total arrangements.
Sign in to write, run, and submit your solution against the full test suite.