2966. Divide Array Into Arrays With Max Difference
You are given an integer array
numsof sizenand a positive integerk.Divide the array into one or more arrays of size
3satisfying the following conditions:
- Each element of
numsshould be in exactly one array.- The difference between any two elements in one array is less than or equal to
k.Return a 2D array containing all the arrays. If it is impossible to satisfy the conditions, return an empty array. And if there are multiple answers, return any of them.
1 | class Solution { |