Skip to content

Commit 64705e5

Browse files
Create README.md
1 parent 766b4d8 commit 64705e5

File tree

1 file changed

+41
-0
lines changed
  • Medium/2616. Minimize the Maximum Difference of Pairs

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# 🧠 Leetcode 2616 - Minimize the Maximum Difference of Pairs
2+
3+
## 📝 Problem Statement
4+
5+
Given a 0-indexed integer array `nums` and an integer `p`, your task is to form `p` pairs of elements such that:
6+
7+
- No index is used in more than one pair.
8+
- The **maximum difference** among all selected pairs is **minimized**.
9+
10+
For any pair `(i, j)`, the **difference** is calculated as:
11+
`|nums[i] - nums[j]|`
12+
13+
Return the **minimum possible value of the maximum difference** among all `p` pairs.
14+
15+
---
16+
17+
## 📌 Example
18+
19+
### Input
20+
```python
21+
nums = [10,1,2,7,1,3], p = 2
22+
```
23+
### Output
24+
```
25+
6
26+
```
27+
28+
### Explanation
29+
+ One optimal selection of pairs:
30+
31+
- Pair 1: (1, 4) → |1 - 1| = 0
32+
33+
- Pair 2: (2, 5) → |2 - 3| = 1
34+
35+
+ The maximum difference is `max(0, 1) = 1`, which is minimal.
36+
37+
---
38+
### 👨‍💻 Author
39+
Built with ❤️ by Muawiya (@Coding_Moves)
40+
41+
---

0 commit comments

Comments
 (0)