Given numRows, generate the first numRows of Pascal's triangle.
For example, given numRows = 5,
Return
Return
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
<Solution>這題是要找出 Pascal's triangle,並不困難,直覺的解法就可以了
- 頭和尾一定都是 1
- 中間就是把上一次結果的 index-1 和 index 的值相加得出目前 index 的值
沒有留言:
張貼留言