bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 119. Pascal's Triangle II

119. Pascal's Triangle II

Leetcode Solutions

Approach: Math! (specifically, Combinatorics)

  1. Initialize an array row with a length of rowIndex + 1 and set the first element to 1.
  2. Iterate from the second element to the last element of the array.
  3. Calculate each element using the formula row[j] = row[j - 1] * (rowIndex - j + 1) / j.
  4. Return the array row as the result.
UML Thumbnail

Approach: Dynamic Programming

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...