hard2-D Dynamic ProgrammingGoogle
Fireworks Bursting Planner
A pyrotechnician bursts a row of balloons in an order that maximizes coins = left·current·right (with implicit 1s outside).
Given nums, you may burst balloons one at a time; bursting i gives nums[i-1]*nums[i]*nums[i+1] coins (with 1 at the ends). Maximize total coins.
Choose approach
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1/6
Narrationstep 1 of 6
Padded = [1,3,1,5,8,1].
Variables
padded=1,3,1,5,8,1
How to think about it
- Fixing 'last burst' decouples the two sides.
- Pad with 1s to simplify boundaries.
Edge cases to catch in interview
- Single balloon n -> n.
- Already padded case ignores padded 1s.
Examples
Example 1
10{"nums":[1,5]}
Try your own input
SpacePlay / pause
← / →Previous / next step
RReset to start
. or >Cycle speed