Burst balloons

nums lists the numbers on a row of balloons. Bursting balloon i earns left * nums[i] * right coins, where left and right are the nearest unburst neighbours (treat the edges as 1), and then the row closes up. Write max_coins(nums) that returns the most coins you can earn by bursting all of them.

max_coins([3, 1, 5, 8])  ->  167
max_coins([1, 5])        ->  10
max_coins([])            ->  0

Think about the last balloon burst in a range: its neighbours are the range's fixed borders. Interval DP over (left border, right border) with padding 1s at both ends.

def max_coins(nums):
    ...