Skip to content

Commit 437976f

Browse files
authored
climbing stairs solution
1 parent 96ab933 commit 437976f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

climbing-stairs/yhkee0404.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Solution {
2+
def climbStairs(n: Int): Int = {
3+
val dp = Array.ofDim[Int](n + 1)
4+
dp(0) = 1
5+
dp(1) = 1
6+
for (i <- 2 to n) {
7+
dp(i) = dp(i - 1) + dp(i - 2)
8+
}
9+
dp(n)
10+
}
11+
}

0 commit comments

Comments
 (0)