https://leetcode.com/problems/climbing-stairs/submissions/
package main
func main() {
// n := 3
// n := 4
// n := 5
n := 6
// n := 7
climbStairs(n)
}
func climbStairs(n int) int {
a, b := 1, 1
for i := 1; i < n; i++ {
next := a + b
a, b = b, next
}
return b
}
'Algorithm > Go' 카테고리의 다른 글
[LeetCode] Remove Element (0) | 2022.01.31 |
---|---|
[LeetCode] Best Time to Buy and Sell Stock (0) | 2022.01.24 |
[LeetCode] Adding Spaces to a String (0) | 2022.01.24 |
[LeetCode] Maximum Subarray (0) | 2022.01.10 |
[LeetCode] Longest Common Prefix (0) | 2022.01.09 |