Given an Array
of N elements and we want to make all elements in array equal we can do 2 following operations
- increase any element by 1
- 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. ?