Search⌘ K
AI Features

Solution: Triangle

Explore how to solve the minimum path sum problem in a triangle using dynamic programming. This lesson teaches you to use a bottom-up method that efficiently computes the optimal path by updating costs from the last row up. You will understand the implementation details, time and space complexity, and why this approach outperforms greedy or plain recursion methods.

Statement

Given an array, triangle, return the minimum path sum from top to bottom.

You may move to an adjacent number in the row below at each step. More formally, if you are at index ii in the current row, you may move to either index ii ...