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

Автор abcuvw, история, 8 месяцев назад, По-английски

I solved this problem using recursive memoization. Can anyone help me with iterative approach? Problem is as follows:

You are given an array A consisting of N numbers. In one move, you can either delete the first two, the last two or the first and last elements of A. No move can be performed if the length of array is less than 2. The result of each move is the sum of deleted elements. Find the maximum number of moves that can be performed such that all moves have same result.

Ex: A= [3,1,5,3,3,4,2] has max number of moves = 3 with result being 6 each time.

N<=1000 and A[i]<=1e9.

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

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