Tap here to switch tabs
Problem
Submissions

Problem: Minimize the Maximum Difference of Pairs

med
30 min
Try to solve the Minimize the Maximum Difference of Pairs problem.

Statement

You are given an integer array nums and an integer p. You need to select p pairs of indices such that no index is used in more than one pair.

The difference between a pair of elements at indices i and j is defined as ∣|nums[i] −- nums[j]∣|.

Return the minimum possible maximum difference among all p pairs. If p is equal to 00, return 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 0≤0 \leq p ≤\leq nums.length /2/ 2

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimize the Maximum Difference of Pairs

med
30 min
Try to solve the Minimize the Maximum Difference of Pairs problem.

Statement

You are given an integer array nums and an integer p. You need to select p pairs of indices such that no index is used in more than one pair.

The difference between a pair of elements at indices i and j is defined as ∣|nums[i] −- nums[j]∣|.

Return the minimum possible maximum difference among all p pairs. If p is equal to 00, return 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 0≤0 \leq p ≤\leq nums.length /2/ 2