Urban Company | OA | SDE1
Anonymous User
2426

Given a list of sorted integers of length n.
We have to remove exactly k integers from the list such that the maximum difference between adjacent elements is minimised.
We cannot remove the first and last element i.e they are fixed.
Constraints :
1 <= n <= 10^5
0<= k <= n-2

Sample Test Case -
n = 5
arr = 1 2 3 7 8
k = 2.
O/P - 5
If we remove 2 and 7 we get the array 1 3 8 and answer is 5 (8-3 = 5) which is the minimum possible answer after removing 2 integers.

Comments (4)