Skip to content

Instantly share code, notes, and snippets.

@azihsoyn
Created June 23, 2021 07:29
Show Gist options
  • Save azihsoyn/58d7227e500d4658cb06f80462823f98 to your computer and use it in GitHub Desktop.
Save azihsoyn/58d7227e500d4658cb06f80462823f98 to your computer and use it in GitHub Desktop.
func generate(numRows int) [][]int {
ret := make([][]int, numRows)
for i := 1; i <= numRows; i++ {
ret[i-1] = make([]int, i)
ret[i-1][0], ret[i-1][i-1] = 1, 1
for j := 2; j < i && j <= numRows-1; j++ {
ret[i-1][j-1] = ret[i-2][j-2] + ret[i-2][j-1]
}
}
return ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment