FastPrepClimb Stairs with One, Two, or Three Steps
Problems/Climb Stairs with One, Two, or Three Steps

Climb Stairs with One, Two, or Three Steps

Agoda logoAgoda● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: We kept the reported rule of taking one, two or three steps at a time. We filled in the missing details: count exactly, what to return for zero steps, and a safe limit.

Our version is about 95% the same as the reported question.

A staircase has n steps. Starting before the first step, each move climbs exactly 1, 2, or 3 steps.

Return the exact number of ordered move sequences that land exactly on step n. For n = 0, return 1 for the empty sequence.

Function

countStairWays(n: int) → long

Examples

Example 1

n = 4return = 7

The seven sequences are 1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2, 1+3, and 3+1.

Example 2

n = 0return = 1

There is one way to climb zero steps: take no moves.

Constraints

  • 0 <= n <= 50
  • The exact answer fits in a signed 64-bit integer.

More Agoda interview questions

  • Sort Ones, Twos, and Threes In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Molecular Weight of a Grouped FormulaONSITE INTERVIEW · Seen Oct 2026
  • Minimum Daily Printing LimitONSITE INTERVIEW · Seen Aug 2026
  • Rank Transform an ArrayONSITE INTERVIEW · Seen Aug 2026
  • Minimum Absolute Difference PairsONSITE INTERVIEW · Seen Jun 2026
  • Feasibility of Printing Within Given DaysONSITE INTERVIEW · Seen May 2026
  • 3SumONSITE INTERVIEW · Seen May 2026
  • Can Place FlowersPHONE SCREEN · Seen Nov 2026
  • Reverse Words in a StringPHONE SCREEN · Seen Nov 2026
  • Disk Space Window AnalyzerPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Climbing StairsAmazon · ONSITE INTERVIEW
  • Climbing StairsAMD · ONSITE INTERVIEWAMD interview questions
  • Climbing StairsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • N-th Fibonacci NumberBank of America · ONSITE INTERVIEWBank of America interview questions
  • Fibonacci with Input ValidationMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • Integral of a Sine PowerJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Climbing StairsExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
  • The Nth Number in the Fibonacci SequenceCapital One · PHONE SCREEN · ONSITE INTERVIEWCapital One interview questions
  • Allocate Mailboxes with Squared DistanceLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions

Agoda interview experiences

  • Agoda Staff Backend OA Questions: 5 Experiences
All Agoda interview questionsSee Agoda hiring insights
Saved
class Solution {
    public long countStairWays(int n) {
        // Write your solution here.
    }
}
Checking account…