Блог пользователя wittybull7

Автор wittybull7, история, 3 года назад, По-английски

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/

Полный текст и комментарии »

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится