题目描述
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]
]
解题
思路
每一行除了第0个元素和最后一个元素除外,current[j] = lastRow[j-1]+lastRow[j];
代码
|
酷爱历史文学的程序猿
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]
]
每一行除了第0个元素和最后一个元素除外,current[j] = lastRow[j-1]+lastRow[j];
|
微信打赏
支付宝打赏
热评文章