Maximum gap linear time
Your task
Given an unsorted integer array nums, return the maximum difference between two successive elements once the array is sorted. If the array has fewer than two elements, return 0. You must run in linear time and use linear extra space, so use bucket sort / the pigeonhole principle (the max gap is at least ceil((max-min)/(n-1)), so it must occur across bucket boundaries), NOT a comparison sort.
Examples
maximum_gap(nums: list[int]) -> intExample 1
Input
maximum_gap([3, 6, 9, 1])Output
3