Skip to content

Commit

Permalink
ADD : DaleStudy#230 by heypaprika
Browse files Browse the repository at this point in the history
  • Loading branch information
heypaprika committed Dec 17, 2024
1 parent 2cb3699 commit fbffa7e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions climbing-stairs/heypaprika.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
๋ณต์žก๋„ : ์˜ˆ์ƒ -> ์˜ˆ์ƒํ•œ ์ด์œ 
์‹œ๊ฐ„ ๋ณต์žก๋„ : O(n) -> ๋ฐฐ์—ด์˜ ๊ธธ์ด n-2 ๋งŒํผ ๋ฐ˜๋ณตํ•˜๋ฏ€๋กœ
๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n) -> n ๊ธธ์ด์˜ ๋ฐฐ์—ด ํ•˜๋‚˜๋ฅผ ์ƒ์„ฑํ•˜๋ฏ€๋กœ
"""
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1:
return 1
elif n == 2:
return 2
a = [0] * n
a[0] = 1
a[1] = 2
for i in range(2, n):
a[i] = a[i-1] + a[i-2]
return a[n-1]

0 comments on commit fbffa7e

Please sign in to comment.