Today, I solved the climbing staris.
Description:
Solution:
Let's say the example(n = 5).
On the 4th stair, we have only 1 way to get 5th stair.
On the 3rd stair, we have (1 + 1) ways to get 5th stair.
On the 2nd stair, we have (2 + 1) ways to get 5th stair.
In my code, we set (n-1)th stair as "one", and nth stair as "two."
We shift those one and two until we get to 0(start point).
(n-1) and (n) is always "1" in any case.
'LeetCode ๐๏ธ > Dynamic Programming' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
198. House Robber (0) | 2023.07.01 |
---|---|
377. Combination Sum IV (0) | 2023.06.30 |
139. Word Break (0) | 2023.06.29 |
300. Longest Increasing Subsequence (0) | 2023.06.28 |
332. Coin Change (0) | 2023.05.26 |