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

Leetcode Problem 120. Triangle

120. Triangle

Leetcode Solutions

Dynamic Programming (Bottom-up: In-place)

  1. Start from the second-to-last row of the triangle and iterate upwards to the first row.
  2. For each cell in the current row, calculate the minimum path sum by adding the cell's value to the minimum of the two adjacent cells in the row below.
  3. Update the current cell with the calculated minimum path sum.
  4. Once the top of the triangle is reached, return the value of the top cell as the minimum path sum.
UML Thumbnail

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...