Question
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.
maximum_gap(nums: list[int]) → int[[3,6,9,1]]out3State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.