118. Pascal's Triangle
Last updated
Last updated
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it.
Example:
其实和之前动态规划问题得到数组中的值有的像,此位置的值等于上两个位置的值相加。可以用二维数组解决,但是这里是可以优化到只用一维数组。每次重复使用即可。
帕斯卡三角形,三角形面积是O(n²)的,每个点都要计算,最后时间复杂度O(n²)