Need help for a DP Problem or maybe not a DP problem

Revision en2, by wittybull7, 2021-06-15 09:47:50

Given an array of integers

You need to make maximum profit by removing numbers until only one number remains in array.

Profit when you remove an array element i = arr[i-1] * arr[i] * arr[i+1]

after the above operation ith element is removed from array

corner elements will have profit = corner element * adjacent element

Example : [3, 5, 1, 8, 2]

  1. Remove 8 : profit = 1*8*2, array = [3, 5, 1, 2]
  2. Remove 1 : profit = 1*8*2 + 5*1*2 array = [3, 5, 2]

and so on..

Asked in an interview, no source available
Tried searching internet, no help found

UPD -> Link : https://leetcode.com/problems/burst-balloons/

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English wittybull7 2021-06-15 09:47:50 61
en1 English wittybull7 2021-06-15 08:31:02 679 Initial revision (published)