Build the first numRows rows of Pascal's triangle and return them as a list of rows, top row first.
The top row is just [1]. Each row below is one number longer: it starts and ends with 1, and every number in between is the sum of the two numbers above it, the one up and to the left plus the one up and to the right.
In the fourth row, 3 = 1 + 2 and 3 = 2 + 1, from the pairs in the row above.
The second row has no inner numbers: just the two 1s at its ends.
The middle of the last row is 20 = 10 + 10.
Constraints
1 <= numRows <= 30Every number in the first 30 rows fits in a 32-bit signed integer.
Build the triangle one row at a time: each row depends only on the row directly above it.
4