Given n balloons with values, bursting a balloon earns coins equal to the product of its two current neighbors' values (using 1 for a missing out-of-bounds neighbor); once burst, its former neighbors become adjacent. Return the maximum coins obtainable by bursting all the balloons.
nums = [3,1,5,8]167Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →The same DP idea as 1-D, but the state depends on two indices — often two positions in a grid, or a position in each of two sequences being compared.
Read the full 2-D Dynamic Programming guide →
Original problem on LeetCode ↗