Skip to content

Practice Pascal's Triangle

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#118
LeetCode Problem

Pascal's Triangle

Problem Statement

Return the first numRows rows of Pascal's triangle. The first row is [1]. Each later row begins and ends with 1; every interior value is the sum of the two adjacent values above it in the preceding row.

Source: Pascal's Triangle on LeetCode. Use the original task for its coding environment and submissions.

Examples

# 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

1 <= numRows <= 30

Related LeetCode Problems

Practice more problems similar to Pascal's Triangle.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.