Maximum gap linear time

Write codeHard30 minGoogle style

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]) -> int
Example 1
Inputmaximum_gap([3, 6, 9, 1])
Output3