You may swap values at any two positions in nums whenever their absolute difference is at most limit. Perform any number of these operations, including zero, and return the lexicographically smallest array you can obtain. To compare two arrays lexicographically, find their first differing position; the array with the smaller value there is smaller.
Example 1:
Input: nums = [5,3,1]
limit = 2
Output: [1,3,5]Explanation: Swap 5 with 3 to get [3,5,1], then 3 with 1 to get [1,5,3], then 5 with 3 to get [1,3,5]. Each swap changes positions of values differing by 2.
Example 2:
Input: nums = [8,1,4]
limit = 2
Output: [8,1,4]Explanation: Every pair of distinct values differs by more than 2, so no swap is allowed. The result stays [8,1,4].
Example 3:
Input: nums = [4,2,2]
limit = 2
Output: [2,2,4]Explanation: Swap the first 4 with the last 2 to get [2,2,4]. This is the smallest ordering of these values.
Constraints:
1 <= nums.length <= 1000001 <= nums[i] <= 10000000001 <= limit <= 1000000000