/119. Pascal's Triangle II

119. Pascal's Triangle II

Easy
Arrays67.2% acceptance

Given a non-negative integer n, return the nth row (0-indexed) of Pascal's Triangle as a list of integers. Each element in the row is the sum of the two elements directly above it from the previous row. The first row (row 0) is [1].

Example 1

Input: 2

Output: [1,2,1]

Explanation: The 2nd row of Pascal's Triangle is [1,2,1].

Example 2

Input: 4

Output: [1,4,6,4,1]

Explanation: The 4th row of Pascal's Triangle is [1,4,6,4,1].

Constraints

  • 0 <= n <= 33
Python (current runtime)

Case 1

Input: 5

Expected: [1,5,10,10,5,1]

Case 2

Input: 7

Expected: [1,7,21,35,35,21,7,1]

Case 3

Input: 10

Expected: [1,10,45,120,210,252,210,120,45,10,1]