Social-Verifier's blog

By Social-Verifier, history, 2 years ago, In English

Given an Array of N elements and we want to make all elements in array equal we can do 2 following operations

  1. increase any element by 1
  2. decrease any element by 1

What is the minimum number of operation we can do to make all elements in array equal. ?

I tried this problem and found that making every element equal to the median of array is optimal is there any proof for this. ?

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it