Compute ways to climb n steps
Company: Paradromics
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This Coding & Algorithms question evaluates recursion and dynamic programming concepts by asking for the count of distinct ways to climb n steps, framed at an algorithmic/implementation level. It is commonly asked because it probes recognition of overlapping subproblems and the ability to optimize naive recursive approaches through subproblem reuse and improved time/space efficiency.
Constraints
- 1 <= n <= 45
Examples
Input: (1,)
Expected Output: 1
Explanation: One step.
Input: (2,)
Expected Output: 2
Explanation: Two ways.
Input: (5,)
Expected Output: 8
Explanation: Fibonacci relation.
Input: (45,)
Expected Output: 1836311903
Explanation: Upper constraint.
Hints
- ways[n] = ways[n-1] + ways[n-2].