← ALL NOTES
Array

2294. Partition Array Such That Maximum Difference Is K

Given nums and k, partition the elements into the minimum number of subsets so that within each subset, max − min ≤ k. Sort, then greedily fill groups until the spread would exceed k.

Loading…