### Aafat_Wapas's blog

By Aafat_Wapas, history, 3 years ago,

Given an array of integers H representing heights of towers and a positive integer B. It is allowed to either increase or decrease the height of every tower by B (only once).

How to calculate the minimum possible difference between the heights of the longest and the shortest tower after modifications.

Note: It is mandatory to either increase or decrease the height of every tower.

• +8

By Aafat_Wapas, history, 3 years ago,

How To Find the minimum value of the expression below:

SUM(|x - A[i]|*B[i]), i >= 0 and i < N, B[i] > 0

When B[i] = 1 I know the answer is given by x = Median(A).How to calculate x when B itself varies.