Given an integer array nums, find the largest gap between any two consecutive numbers once the array is sorted in ascending order.
If nums has fewer than two numbers, return 0.
Your solution should run in linear time and use only linear extra space.
Input: nums = [3,6,9,1]
Output: 3
Explanation:
Sorted array → [1,3,6,9] The consecutive differences are: 3-1 = 2, 6-3 = 3, 9-6 = 3. The largest gap is 3.
Input: nums = [10]
Output: 0
Explanation:
There is only one number, so no gap can be calculated.
Accepted:
Submission: