Generate the first rows of Pascal's triangle, where each number is the sum of the two numbers directly above it.
Given an integer numRows, return the first numRows rows of Pascal's Triangle.
Pascal's Triangle is built row by row:
[1].1.Your task is to construct and return the triangle up to the requested number of rows.
numRows.numRows is the number of rows to generate.numRows rows of Pascal's Triangle.Example 1
Input
numRows = 5
Output
[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
Explanation
Start with [1]. Each new row is formed by adding adjacent pairs from the previous row, with 1 at both ends.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.