DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
DP

Climbing Stairs

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Climbing Stairs** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Fibonacci recurrence dp[i] = dp[i-1] + dp[i-2] **Edge Cases to Consider:** - (1) n = 1 - (2) n = 2 - (3) Very large n (overflow)

Examples

Example 1
Input: 1
Output: 1
Explanation: Only one way
Example 2
Input: 2
Output: 2
Explanation: {1,1} or {2}
Example 3
Input: 3
Output: 3
Explanation: {1,1,1},{1,2},{2,1}

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪n = 1
  • ▪n = 2
  • ▪Very large n (overflow)
Frequently Asked At
AmazonGoogleMicrosoftMetaAdobeTCSInfosys