package leetcode;

/**
 * https://leetcode.com/problems/smallest-range-ii/
 */
public class Problem910 {
    public int smallestRangeII(int[] A, int K) {
        // TODO
        return 0;
    }

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

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -185,24 +185,40 @@
     
-// TODO%0A
+if (A.length == 1) %7B%0A   
         
 retu
@@ -213,16 +213,17 @@
         
+ 
 return 0
@@ -224,16 +224,453 @@
 turn 0;%0A
+        %7D%0A        Arrays.sort(A);%0A        int answer = Integer.MAX_VALUE;%0A        for (int i = 0; i %3C A.length - 1; i++) %7B%0A            if ((A%5Bi%5D + K) == (A%5Bi + 1%5D + K)) %7B%0A                continue;%0A            %7D%0A            int hi = A%5Bi%5D + K;%0A            int lo = A%5Bi + 1%5D - K;%0A            answer = Math.min(answer, Math.abs(hi - lo));%0A        %7D%0A        answer = Math.min(answer, Math.abs(A%5BA.length - 1%5D - A%5B0%5D));%0A        return answer;%0A
     %7D%0A%0A 
@@ -757,16 +757,18 @@
 m910();%0A
+//
         
@@ -831,16 +831,92 @@
 ); // 0%0A
+//        System.out.println(prob.smallestRangeII(new int%5B%5D%7B1%7D, 5)); // 0%0A//
         
@@ -983,16 +983,18 @@
 ); // 6%0A
+//
         
@@ -1063,16 +1063,352 @@
 ); // 3%0A
+//        System.out.println(prob.smallestRangeII(new int%5B%5D%7B1, 3, 7, 4, 1, 10, 8, 11%7D, 4)); // 5%0A//        System.out.println(prob.smallestRangeII(new int%5B%5D%7B2, 7, 2%7D, 1)); // 3%0A//        System.out.println(prob.smallestRangeII(new int%5B%5D%7B7, 8, 8%7D, 5)); // 1%0A        System.out.println(prob.smallestRangeII(new int%5B%5D%7B1, 3, 10%7D, 4)); // 2%0A
     %7D%0A%7D%0A

Update problem 910