A marketing banner is a strip n units wide. A designer fills it from left to right with tiles that are 1, 2, or 3 units wide, with no gaps and no overlap. The order matters: a 1-unit tile followed by a 2-unit tile is a different layout from a 2 followed by a 1.
Write countTilings(n) that returns the number of different layouts that fill the strip exactly. An empty strip (n = 0) has exactly one layout: no tiles.
Input: n = 3 Output: 4
1+1+1, 1+2, 2+1, and 3.
Input: n = 4 Output: 7
Layouts ending with a 1 (4 of them), a 2 (2 of them), or a 3 (1 of them).
0 <= n <= 36Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #484 Tile a Banner Strip. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.