package leetcode;

/**
 * https://leetcode.com/problems/smallest-range-i/description/
 */
public class Problem908 {
    public int smallestRangeI(int[] A, int K) {
        // TODO
        return 0;
    }

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

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -195,352 +195,175 @@
     
-// TODO%0A        return 0
+Arrays.sort(A)
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem908 prob = new Problem908();%0A        System.out.println(prob.smallestRangeI(new int%5B%5D%7B1%7D, 0)); // 0%0A        System.out.println(prob.smallestRangeI(new int%5B%5D%7B0, 10%7D, 2)); // 6%0A        System.out.println(prob.smallestRangeI(new int%5B%5D%7B1, 3, 6%7D, 3)); // 0
+if (A.length %3C= 1) %7B%0A            return 0;%0A        %7D%0A        int diff = (A%5BA.length - 1%5D - K) - (A%5B0%5D + K);%0A        return diff %3C 0 ? 0 : diff;
 %0A   

Solve problem 908