package leetcode;

/**
 * https://leetcode.com/problems/maximum-gap/
 */
public class Problem164 {
    public int maximumGap(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem164 prob = new Problem164();
        System.out.println(prob.maximumGap(new int[]{3, 6, 9, 1})); // 3
        System.out.println(prob.maximumGap(new int[]{10})); // 0
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -170,267 +170,299 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem164 prob = new Problem164();%0A        System.out.println(prob.maximumGap(new int%5B%5D%7B3, 6, 9, 1%7D)); // 3%0A        System.out.println(prob.maximumGap(new int%5B%5D%7B10%7D)); // 0
+if (nums.length %3C 2) %7B%0A            return 0;%0A        %7D%0A        Arrays.sort(nums);%0A        int answer = 0;%0A        for (int i = 0; i %3C nums.length - 1; i++) %7B%0A            int diff = Math.abs(nums%5Bi%5D - nums%5Bi + 1%5D);%0A            answer = Math.max(answer, diff);%0A        %7D%0A        return answer;
 %0A   

Solve problem 164