Get exceptionally good at coding interviews by solving one problem every day.
No spam, ever. Easy unsubscribe.
Get tailored problems from our experts who have interviewed at top companies.
Solve problems every day before you get the solutions the next morning.
Verify your work and get better at problem solving until you land the job!
There's a staircase with N steps, and you can climb 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters.
For example, if N is 4, then there are 5 unique ways:
What if, instead of being able to climb 1 or 2 steps at a time, you could climb any number from a set of positive integers X? For example, if X = {1, 3, 5}, you could climb 1, 3, or 5 steps at a time. Generalize your function to take in X.