You are coding as a Guest. Sign in with your RoleNest account to permanently track your streak, earn XP, and climb the Campus Leaderboard!
Sign In with RoleNestProblem Set
🔥Climbing Stairs: Dynamic Step CombinationsEasy
DAILY PROBLEM OF THE DAY+50 XP • Daily Streak
Solve today's challenge or tackle one of the 3 Super Hard challenges for +150 XP.
EasyDynamic Programming•Acceptance: 52.8%
Climbing Stairs: Dynamic Step Combinations
Targeted in FAANG & Tech OA:AmazonGoogleUber
Real-World Engineering Context
Fibonacci state transition modeling in CPU instruction pipeline scheduling and branch predictor warm-up cycles.
You are climbing a staircase. It takes `n` steps to reach the top. Each time you can either climb 1 or 2 steps.
In how many distinct ways can you climb to the top?
Sample Test Cases
Input: [2]
Expected: 2
Input: [3]
Expected: 3
Input: [5]
Expected: 8
Input: [1]
Expected: 1
Constraints
- 1 <= n <= 45
Recruiter Fast-Track ReferralVerified Candidate
Direct pipeline to Google, Amazon, Microsoft, Swiggy, & Uber recruiters
Top DevScore profiles bypass resume screening filters. Every verified problem solve writes authentic proof-of-work to your profile and dispatches you directly into employer inboxes on RoleNest.
Explore 5,000+ Direct ATS Openings on RoleNest ↗✓ Direct Referral Active
Language:
Ready to test. Click Run Code or Submit Solution to run test cases in isolated browser sandbox.