增加新题目

This commit is contained in:
JACKYMYPERSON
2025-09-01 20:17:03 +08:00
parent 72f4dca9ed
commit 14a6771b9a
7 changed files with 188 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
package main
func main() {
}
func climbStairs(n int) int {
if n == 1 {
return 1
}
if n == 2 {
return 2
}
stepn1 := 1
stepn2 := 2
for i := 3; i <= n; i++ {
current := stepn1 + stepn2
stepn1, stepn2 = stepn2, current
}
return stepn2
}