Back to problems Sign in to unlock
Leetcode
Medium
Arrays
Math
Combinatorics
Pascal's Triangle II
Return the -th row of Pascal's Triangle using only the row index.
Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Pascals Triangle Ii
gfgPrimary
Problem Statement
Pascal's Triangle II
Given an integer rowIndex, return the rowIndex-th row of Pascal's Triangle (0-indexed).
In Pascal's Triangle, each number is the sum of the two numbers directly above it in the previous row. The first row is [1], the second row is [1, 1], and so on.
Build and return the requested row as a list of integers.
Input Format
- A single integer
rowIndexrepresenting the 0-indexed row to generate.
Output Format
- Return a list of integers containing the
rowIndex-th row of Pascal's Triangle.
Constraints
- The answer fits in a 32-bit signed integer.
Examples
Sample cases returned by the problem API.
Example 1
Input
rowIndex = 3
Output
[1,3,3,1]
Explanation
The first four rows are [1], [1,1], [1,2,1], and [1,3,3,1].
Example 2
Input
rowIndex = 0
Output
[1]
Explanation
The 0-th row contains only one value.
Premium problem context
Unlock deeper context for this problem
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.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.