Skip to content

Commit 4af9171

Browse files
feat: climbStairs
1 parent ca238f6 commit 4af9171

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

climbing-stairs/changchanghwang.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Time complexity, O(n)
2+
// Space complexity, O(1)
3+
// 피보나치 수열로 풀이가 가능하다.
4+
func climbStairs(n int) int {
5+
a, b := 1, 1
6+
for ; n > 1; n-- {
7+
a, b = b, a+b
8+
}
9+
return b
10+
}

0 commit comments

Comments
 (0)