@playwithedith: LeetCode 70: Climbing Stairs. 45 stairs, and counting every path takes over 2 billion calls. Here's the shortcut. Explained with Edithly: turn any document, link or problem into an interactive visual. Try it at app.edithly.com The problem: you climb 1 or 2 steps at a time, so how many different ways get you up n stairs? Listing every path is a recursion tree that blows up, about 2.3 billion calls for 45 stairs. Look at the last move instead. You reach the top from one step below or from two below, so ways(n) = ways(n-1) + ways(n-2). Build up from the bottom: 1, 2, 3, 5, 8. Five stairs have 8 ways. Keep only the last two counts and the answer for 45 stairs takes 43 additions, O(n) time and O(1) space. It's the first dynamic programming problem most people meet, and the same idea runs House Robber and Decode Ways. Full step-by-step solvesheet (made with Edithly): app.edithly.com/links/u/6b05a160be1bb82875629237 Send this to someone prepping for interviews. Follow for the full Blind 75. #leetcode #dynamicprogramming #codinginterview #dsa #python

Edith | LeetCode riddles
Edith | LeetCode riddles
Open In TikTok:
Region: US
Sunday 29 November 2026 20:02:10 GMT
0
0
0
0

Music

Download

Comments

There are no more comments for this video.
To see more videos from user @playwithedith, please go to the Tikwm homepage.

Other Videos


About