A checkout page has a stepper with steps numbered 0 to n. You start on step 0. Each click on "Next" moves you forward 1 step, and each click on "Skip ahead" moves you forward 2 steps. You can never move past step n.
Write countClickPaths(n) that returns how many different click sequences take you from step 0 to exactly step n. Two sequences are different if they differ at any click.
Input: n = 2 Output: 2
Next + Next, or one Skip ahead.
Input: n = 4 Output: 5
1+1+1+1, 2+1+1, 1+2+1, 1+1+2, and 2+2.
1 <= n <= 45Run 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 #483 Stepper Click Paths. 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.