Climbing Stairs
Updated
Problem statement
Return the number of distinct ordered ways to climb exactly n steps when each move climbs one or two steps. Move order matters: one then two differs from two then one.
Function
climbStairs(n: int) → intExamples
Example 1
n = 1return = 1There is one sequence: a single one-step move.
Example 2
n = 4return = 5The five sequences are 1+1+1+1, 1+1+2, 1+2+1, 2+1+1 and 2+2.
Constraints
1 <= n <= 45- Each move climbs exactly one or two steps.
More BAMTECH Media Phone Screen questions
Similar questions at other companies
- Best Time to Buy and Sell StockMeta · PHONE SCREENMeta interview questions
- Best Time to Buy and Sell StockSwiggy · PHONE SCREEN
- Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Dice Sum That Is a Multiple of mSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
- Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Count Staircase WaysGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
- Suffix Maximum Frequency QueriesMicrosoft · PHONE SCREENMicrosoft interview questions
- Best Time to Buy and Sell StockOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
- Best Time to Buy and Sell StockJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
- Climbing StairsGoogle · PHONE SCREENGoogle interview questions