← Discussions on Climbing Stairs
J jahnavisub6
14 Sep 2026, 06:27

Finally got AC after 3 WAs. Sharing what I missed.

Define dp[i] as the answer for the first i elements and write the transition from smaller states. Once it works, notice you only need the previous row/value, so space drops to O(1) or O(n).

3 replies

aaravsingh 1 month ago

Same idea, but I used a deque. Works fine.

pgupta 1 month ago

Nice. Got asked a variant of this in an interview.

sneha_41 4 weeks ago

Thanks! The dry run on the second example made it click.

Sign in to reply.