Count Staircase Ways
Updated
Problem statement
A staircase has n steps. Starting before the first step, each move climbs exactly one or two steps.
Return the number of distinct ordered move sequences that land exactly on step n. For n = 0, return 1 for the empty sequence.
Function
countStaircaseWays(n: int) → longExamples
Example 1
n = 4return = 5The valid step sequences are 1111, 112, 121, 211, and 22.
Example 2
n = 0return = 1The empty climb is one valid way.
Constraints
0 <= n <= 90- The answer fits in a signed 64-bit integer.
More Goldman Sachs Phone Screen questions
- House Robber IIIPHONE SCREEN · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Is a Power of TenPHONE SCREEN · Seen Oct 2026
- Minimum Traveling Salesperson TourPHONE SCREEN · Seen Oct 2026
- Square Root with Newton IterationPHONE SCREEN · Seen Oct 2026
- First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 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
- Climbing StairsGoogle · PHONE SCREENGoogle 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