19.Burst Balloons
You are given n
balloons, indexed from 0
to n - 1
. Each balloon is painted with a number on it represented by an array nums
. You are asked to burst all the balloons.
If you burst the ith
balloon, you will get nums[left] * nums[i] * nums[right]
coins. Here left
and right
are adjacent indices of i
. After the burst, the left
and right
then becomes adjacent.
Return the maximum coins you can collect by bursting the balloons wisely.
Solution: (Bottom Up DP)
Time Complexity:- O(n^3) Space Complexity:- O(2n)
Last updated