Skip to content
Onsite

Pascal's Triangle

EasyP3Coding

Return the first numRows rows of Pascal's triangle.

Row 0 is [1]. Every other row has one more element than the row before it; its first and last elements are 1, and every element in between is the sum of the two elements above it in the previous row.

Example 1

Input
numRows = 5
Output
[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]

Example 2

Input
numRows = 1
Output
[[1]]

Constraints

  • 0 <= numRows <= 30

Hints

Run checks the 3 visible tests, Submit all 10.