Pascal's Triangle

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.

Example 1
InputnumRows = 5
Output[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
The first 5 rows of Pascal's triangle are returned.
Example 2
InputnumRows = 1
Output[[1]]
The first 1 row of Pascal's triangle is returned.

Constraints

  • 1 <= numRows <= 30

Asked at 18 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate