杨辉三角 II(1025-go)
func getRow(rowIndex int) []int {
res := make([][]int, rowIndex+1)
for i := 0; i <= rowIndex; i++ {
res[i] = make([]int, i+1)
res[i][0] = 1
res[i][i] = 1
}
for i := 1; i <= rowIndex; i++ {
for j := i; j < i; j++ {
res[i][j] = res[i-1][j] + res[i-1][j-1]
}
}
return res[rowIndex]
}
func getRow11(rowIndex int) []int {
res := make([]int, rowIndex+1)
res[0] = 1
for i := 1; i < rowIndex+1; i++ {
res[0] = 1
res[i] = 1
for j := i - 1; j >= 1; j-- {
res[j] = res[j] + res[j-1]
}
}
return res
}