You are given a 0-indexed integer array
nums and an integer
p pairs of indices of
nums such that the maximum difference amongst all the pairs is minimized. Also, ensure no index appears more than once amongst the
Note that for a pair of elements at the index
j, the difference of this pair is
|nums[i] - nums[j]|, where
|x| represents the absolute value of
Return the minimum maximum difference among all
p pairs. We define the maximum of an empty set to be zero.
Input: nums = [10,1,2,7,1,3], p = 2 Output: 1 Explanation: The first pair is formed from the indices 1 and 4, and the second pair is formed from the indices 2 and 5. The maximum difference is max(|nums - nums|, |nums - nums|) = max(0, 1) = 1. Therefore, we return 1.
Input: nums = [4,2,1,2], p = 1 Output: 0 Explanation: Let the indices 1 and 3 form a pair. The difference of that pair is |2 - 2| = 0, which is the minimum we can attain.
1 <= nums.length <= 105
0 <= nums[i] <= 109
0 <= p <= (nums.length)/2