# LC 2616 minimize-the-maximum-difference-of-pairs
[https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/](https://)
```python=
class Solution:
def minimizeMax(self, nums: List[int], p: int) -> int:
if p==0: return 0
nums.sort()
s = [nums[i]-nums[i-1] for i in range(1,len(nums))]
n = len(s) # to find p non-adjacent in s
def enough(v): # if <= v is enough
i,cnt = 0,0
while i<n and cnt<p:
if s[i]<=v:
cnt += 1
i += 2
else: i += 1
return cnt>=p
# binary search
if enough(0): return 0
curr = 0 # the max not enough
oo = max(s)
jump = oo//2
while jump:
while curr+jump<oo and not enough(curr+jump):
curr += jump
jump >>= 1
return curr+1
```