Skip to content

Commit fac1fba

Browse files
committed
feat: Add solution for LeetCode problem 70
1 parent 6dc43b9 commit fac1fba

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

climbing-stairs/WhiteHyun.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// 70. Climbing Stairs
3+
// https://leetcode.com/problems/climbing-stairs/description/
4+
// Dale-Study
5+
//
6+
// Created by WhiteHyun on 2024/05/12.
7+
//
8+
9+
final class Solution {
10+
func climbStairs(_ n: Int) -> Int {
11+
var dp: [Int] = .init(repeating: 0, count: 45)
12+
dp[0] = 1
13+
dp[1] = 2
14+
for i in 2 ..< 45 {
15+
dp[i] = dp[i - 1] + dp[i - 2]
16+
}
17+
return dp[n - 1]
18+
}
19+
}

0 commit comments

Comments
 (0)