Given an unsorted array, return the maximum difference between successive elements in its sorted form. Bucket-based counting is the standard way to solve it in linear time when the value range is large.
nums = array of non-negative integers
maximum successive gap in sorted order
Example 1:
Input:
nums = [3,6,9,1]
Output:
3
Explanation:
The sorted array is [1,3,6,9], and the largest gap is 3.
Example 2:
Input:
nums = [10]
Output:
0
Explanation:
With fewer than two numbers, the gap is 0.