增加新题目

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,9 @@
package main
func main() {
}
func rob(nums []int) int {
return 0
}

View File

@@ -0,0 +1,29 @@
package main
func main() {
}
func generate(numRows int) [][]int {
reslist := make([][]int, 0)
for i := 0; i < numRows; i++ {
tmpnumlist := make([]int, 0)
if i == 0 {
tmpnumlist = append(tmpnumlist, 1)
reslist = append(reslist, tmpnumlist)
continue
}
for j := 0; j < i+1; j++ {
if j-1 < 0 {
tmpnumlist = append(tmpnumlist, reslist[i-1][0])
continue
} else if j == len(reslist[i-1]) {
tmpnumlist = append(tmpnumlist, reslist[i-1][j-1])
continue
}
tmpnumlist = append(tmpnumlist, reslist[i-1][j]+reslist[i-1][j-1])
}
reslist = append(reslist, tmpnumlist)
}
return reslist
}

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
}