Minimise the maximum difference between the heights

Revision en1, by Aafat_Wapas, 2019-08-01 12:30:57

Given an array of integers H representing heights of towers and a positive integer K. 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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Aafat_Wapas 2019-08-01 19:12:58 2 Tiny change: 'e integer K.\nIt is a' -> 'e integer B.\nIt is a'
en2 English Aafat_Wapas 2019-08-01 12:32:10 4
en1 English Aafat_Wapas 2019-08-01 12:30:57 454 Initial revision (published)