convert one array to another

Revision en1, by Sudhanshu_Kumar, 2019-10-28 08:04:48

Found this interesting problem:

Two integer arrays A and B are given. We need to convert array A to array B using some operation. Operation is defined as follows: Select any element from A decrease its value by 1 and add it to one of the two neighbours.

The array given is circular, meaning the last element can give its value to the first element.

Find the minimum cost to convert array A to array B, where cost id defined as the distance between them, distance between any consecutive element is 1.

Constraints: A,B<=100.

Any suggestion to proceed to this problem.

Tags #help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Sudhanshu_Kumar 2019-10-28 09:34:44 297
en1 English Sudhanshu_Kumar 2019-10-28 08:04:48 614 Initial revision (published)