public int maximumGap_bucket(int[] num) {
        if (num.length < 2) return 0;

        int max = findMinMax(num, 1);
        int min = findMinMax(num, -1);

        int buckets = num.length - 1;
        double step = (max - min + 0.0) / buckets;

        // bucketize
        Map<Integer, List<Integer>> bucketMinMax = bucketize(num, min, step);

        int lastMax = bucketMinMax.get(0).size() > 1 ? bucketMinMax.get(0).get(1) : bucketMinMax.get(0).get(0);
        int maxGap = lastMax - min;
        for (int i = 1; i < buckets; i++) {
            List<Integer> list = bucketMinMax.get(i);
            if (list != null && list.size() > 0) {
                maxGap = Math.max(maxGap, list.get(0) - lastMax);
                lastMax = list.size() > 1 ? list.get(1) : list.get(0);
            }
        }
        return maxGap;
    }