>_
Compiler Shell v1.0.4
Connection to data node secure.
Parsed 600 algorithm challenges.
Mounted telemetry indexes.
> Launching prep command center...
Compiling 0%
Easy 💻 Coding

[Computer Networks] Climbing Stairs DP

Problem Statement

Problem Statement for Climbing Stairs DP under Computer Networks:

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?

Input Constraints:
- 1 <= len(nums) <= 10^5
- Elements fit in memory standard spaces.

Proposed Solution

def climbStairs(n):
    if n <= 2:
        return n
    dp = [0] * (n + 1)
    dp[1] = 1
    dp[2] = 2
    for i in range(3, n + 1):
        dp[i] = dp[i-1] + dp[i-2]
    return dp[n]

Your Progress

Pending Completion

Save Progress?

Login to sync your solutions across all dynamic local and remote sessions.

Join Techlance
Back to Curriculum