Overview
Bursting a balloon changes the adjacent balloons for its neighbors. This means subproblems overlap and interfere if we process them in the normal forward direction.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Maximize coins collected by bursting balloons. Bursting a balloon multiplies its value with its adjacent unburst balloons.
Bursting a balloon changes the adjacent balloons for its neighbors. This means subproblems overlap and interfere if we process them in the normal forward direction.
Instead of guessing which balloon to burst first, we guess which balloon is burst LAST in an interval [i, j].
If balloon k is burst last, then the subproblems [i, k-1] and [k+1, j] are completely independent, allowing us to use DP.
The balloon burst last in interval [i, j] will be adjacent to the boundaries i-1 and j+1. Its coin yield is `nums[i-1] * nums[k] * nums[j+1]`.