#119

Pascal's Triangle II

pupil · 315 · lc easy +21 · verified · 67.2% accepted · 5,288 likes · top 73%

play →

Description

Given a 0-indexed row number rowIndex, return that row of Pascal's triangle as a list.

In Pascal's triangle, each element is the sum of the two elements directly above it.

Example 1:

Input: rowIndex = 3
Output: [1,3,3,1]

Example 2:

Input: rowIndex = 0
Output: [1]

Example 3:

Input: rowIndex = 1
Output: [1,1]

Code

1
2
3