ananddeb23 / minimize-the-heights Goto Github PK
View Code? Open in Web Editor NEWGiven an array A[ ] denoting heights of N towers and a positive integer K, modify the heights of each tower either by increasing or decreasing them by K only once and then find out the minimum difference of the heights of shortest and longest towers. Example Input : A[] = {1, 15, 10}, k = 6 Output : 5 Explanation : We change 1 to 6, 15 to 9 and 10 to 4. Maximum difference is 5 (between 4 and 9). We can't get a lower difference.(GeeksforGeeks)