LeetCode118.  Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.

For example, given numRows = 5,
Return


[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]


很简单,递推就行了,首先摆出特殊的第一个数组【1】,以后的每一层,都是首先一个1,然后是上一个数组t0所有的t0[i]和t0[i+1]的和,最后再添个1.

Day11 Pascal's Triangle

相关文章: