Aafat_Wapas's blog

By Aafat_Wapas, history, 5 years ago, In English

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.

Full text and comments »

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

By Aafat_Wapas, history, 5 years ago, In English

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.

Full text and comments »

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