Making All Elements of Array Equal

Правка en1, от Social-Verifier, 2022-01-14 13:07:51

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. ?

Теги array, median

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Social-Verifier 2022-01-14 13:07:51 436 Initial revision (published)