Created
June 23, 2021 07:29
-
-
Save azihsoyn/58d7227e500d4658cb06f80462823f98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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