Equalize the array

Revision en1, by redcoder23, 2020-07-30 11:19:56

You have N candies distributed unevenly in N containers. You can move one candy from a container to an adjacent container. You have to make moves such that finally each container has one candy. What is the strategy that minimizes the number of moves to keep the time complexity O(N)?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English redcoder23 2020-07-30 11:19:56 301 Initial revision (published)