Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

118. Pascal's Triangle

In Pascal’s triangle, each number is the sum of the two numbers directly above it.

Example:

1
2
3
4
5
6
7
8
9
Input: 5
Output:
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]

想起一開始學Java用雙迴圈解(遠目),當然可以用Python做一次,但對O(nˆ2)不太滿意,就參考網友動態規劃的做法。


如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)

Welcome to my other publishing channels