Help Needed in solving the problem

Правка en1, от DaviddeGea1, 2020-02-09 23:10:00

I got this question in a company's coding round:

Find the minimum cost to make all the elements of an array equal, when 2 operations can be performed-

  1. Increment an element by 1 which costs 'a' units
  2. Decrement an element by 1 which costs 'b' units

Constraints: Array size <= 10^5 a,b <= 10^5 0 <= element <= 10^6

Теги array, math, #implementation

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский DaviddeGea1 2020-02-09 23:10:41 6 (published)
en1 Английский DaviddeGea1 2020-02-09 23:10:00 368 Initial revision (saved to drafts)