← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Google/Leetcode 312. Burst Balloons
CodingOptional
You have n balloons arranged in a row, each labeled with a number representing its value. When you pop balloon i, you earn coins equal to balloons[i-1] * balloons[i] * balloons[i+1]. After popping a balloon, the adjacent balloons become neighbors.
For balloons at the boundaries, treat out-of-bounds positions as having a value of 1. For example, popping the first balloon earns 1 * balloons[0] * balloons[1] coins.
Your task is to determine the maximum total coins you can collect by popping all the balloons in an optimal order.
n == balloons.length1 <= n <= 3000 <= balloons[i] <= 100Example 1:
` Input: balloons = [3, 1, 5, 8] Output: 167 Explanation: One optimal sequence:
Example 2:
` Input: balloons = [1, 5] Output: 10 Explanation: