Climbing Stairs
Updated
Problem statement
You are climbing a staircase with n steps.
On each move, you may climb either 1 step or 2 steps. Return the number of distinct sequences of moves that reach exactly the top.
Function
climbStairs(n: int) → intExamples
Example 1
n = 2return = 2The two valid sequences are 1 + 1 and 2.
Example 2
n = 5return = 8Every valid sequence ends with either a 1-step move from step 4 or a 2-step move from step 3, giving 5 + 3 = 8 sequences.
Constraints
1 <= n <= 45.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- 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
- Count Routes Through a City GridIMC Trading · PHONE SCREENIMC Trading interview questions
- Ways to Climb n StairsAdobe · PHONE SCREENAdobe interview questions
- Heads in Fair Coin FlipsJane Street · PHONE SCREENJane Street interview questions
- Climbing StairsBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Climbing StairsExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
- Cumulative Fibonacci SumZillow · OA · PHONE SCREENZillow interview questions