Trains the technique from
LeetCode 2616Minimize the Maximum Difference of PairsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A workshop's gears have the tooth counts teeth. A mesh joins two of the gears, and no gear may take part in more than one mesh. The slip of a mesh is how far apart its two tooth counts are.
Form exactly p meshes so that the largest slip among them is as small as it can be, and return that largest slip. When p is zero there is nothing to form and the answer is 0.
Example 1
Sorted, the counts read 1, 2, 4, 5, 7, 8. Meshing 1 with 2 and 4 with 5 gives two meshes that each slip by one, and no pair of meshes gets both slips down to nothing.
Example 2
Six gears and three meshes leaves nothing out, so one mesh has to bridge the low group and the high group. Meshing 0 with 1 and 11 with 12 leaves 2 with 10 as the narrowest bridge available.
Example 3
No meshes are asked for, so there is no slip to report.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def minimize_max(teeth: list[int], p: int) -> int:public int minimizeMax(int[] teeth, int p)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.