Google | Onsite | Burst Balloons
Anonymous User
1979

Hi,

Got this for Google 2 days ago and just couldn't come up with a solution for it and haven't found it on LC yet. Please link it if you know it.

Given a list, pick any number and take the product of it's left and right neighbors. Keep doing this until the list is empty. Return the max possible sum of all the products that were selected.

Sample input
[5, 1, 3, 4]
5 * 1 * 3 (choose 1) + 5 * 3 * 4 (choose 3) + 5 * 4 * 1 (choose 4) + 1 * 5 * 1 (choose 5) = 100

Comments (5)