Maximum Gap

Solution Code
max_gap = 0
        prev_max = min_val
        
        for i in range(bucket_count):
            if buckets[i][0] == float('inf'):
                continue  # Skip empty buckets
                
            max_gap = max(max_gap, buckets[i][0] - prev_max)
            prev_max = buckets[i][1]
            
        return max_gap

Time Complexity

O(N)

Space Complexity

O(N)