Description
Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it.
Examples
Input:
numRows = 5Output:
[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]Explanation:
The first 5 rows of Pascal's triangle.
Input:
numRows = 1Output:
[[1]]Explanation:
Just the first row.
Input:
numRows = 4Output:
[[1],[1,1],[1,2,1],[1,3,3,1]]Explanation:
The first 4 rows of Pascal's triangle. Row 0 has [1], row 1 has [1,1], row 2 has [1,2,1] where 2 = 1+1, and row 3 has [1,3,3,1] where the first 3 = 1+2 and the second 3 = 2+1 from the row above.
Constraints
- •
1 ≤ numRows ≤ 30