Cookbook add 0118 solution

This commit is contained in:
YDZ
2020-08-19 08:34:16 +08:00
parent 2c2ca375d9
commit c830ce27af
5 changed files with 93 additions and 8 deletions

View File

@ -0,0 +1,17 @@
package leetcode
func generate(numRows int) [][]int {
result := [][]int{}
for i := 0; i < numRows; i++ {
row := []int{}
for j := 0; j < i+1; j++ {
if j == 0 || j == i {
row = append(row, 1)
} else if i > 1 {
row = append(row, result[i-1][j-1]+result[i-1][j])
}
}
result = append(result, row)
}
return result
}