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 = 5
Output:[[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 = 1
Output:[[1]]
Explanation:

Just the first row.

Input:numRows = 4
Output:[[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

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!