Problem
A row of balloons has numbers nums[i]. When you burst balloon i, you earn left * nums[i] * right coins, where left and right are its current neighbours (balloons that have not been burst yet). If a neighbour does not exist, treat it as a balloon with number 1. After bursting, the neighbours become adjacent. Burst all the balloons and return the maximum coins you can collect.
Example 1
- Input
- nums = [3, 1, 5, 8]
- Output
- 167
Example 2
- Input
- burst 1: 3*1*5 = 15
- Output
- [3, 5, 8]
Example 3
- Input
- burst 5: 3*5*8 = 120
- Output
- [3, 8]
Example 4
- Input
- burst 3: 1*3*8 = 24
- Output
- [8]
Example 5
- Input
- burst 8: 1*8*1 = 8
- Output
- total 167
Example 6
- Input
- nums = [1, 5]
- Output
- 10
Constraints
1 <= nums.length <= 3000 <= nums[i] <= 100