package leetcode;

import java.util.Arrays;
import java.util.List;

/**
 * https://leetcode.com/problems/smallest-range/
 */
public class Problem632 {
    public int[] smallestRange(List<List<Integer>> nums) {
        // TODO
        return new int[0];
    }

    public static void main(String[] args) {
        Problem632 prob = new Problem632();
        System.out.println(prob.smallestRange(Arrays.asList(
            Arrays.asList(4, 10, 15, 24, 26),
            Arrays.asList(0, 9, 12, 20),
            Arrays.asList(5, 18, 22, 30)
        ))); // [20,24]
    }
}

@@ -59,16 +59,42 @@
 il.List;
+%0Aimport java.util.TreeSet;
 %0A%0A/**%0A *
@@ -241,41 +241,1184 @@
     
-// TODO%0A        return new int%5B0%5D
+TreeSet%3CInteger%3E set = new TreeSet%3C%3E();%0A        for (int i = 0; i %3C nums.size(); i++) %7B%0A            List%3CInteger%3E list = nums.get(i);%0A            for (int j = 0; j %3C list.size(); j++) %7B%0A                int val = list.get(j);%0A                boolean found = true;%0A                for (int k = 0; k %3C nums.size(); k++) %7B%0A                    int lo = nums.get(k).get(0);%0A                    int hi = nums.get(k).get(nums.get(k).size() - 1);%0A                    if (lo %3E val %7C%7C val %3E hi) %7B%0A                        found = false;%0A                    %7D%0A                %7D%0A                if (found) %7B%0A                    set.add(val);%0A                %7D%0A            %7D%0A        %7D%0A        int%5B%5D result = new int%5B2%5D;%0A        int i = 0;%0A        int prev = 0;%0A        int min = Integer.MAX_VALUE;%0A        for (int val : set) %7B%0A            if (i == 0) %7B%0A                prev = val;%0A            %7D else %7B%0A                int diff = val - prev;%0A                if (diff %3C min) %7B%0A                    diff = min;%0A                    result%5B0%5D = prev;%0A                    result%5B1%5D = val;%0A                %7D%0A                prev = val;%0A            %7D%0A            i++;%0A        %7D%0A        return result
 ;%0A  
@@ -1538,16 +1538,32 @@
 println(
+Arrays.toString(
 prob.sma
@@ -1716,24 +1716,24 @@
 22, 30)%0A
-
         
 ))); // 
@@ -1724,16 +1724,17 @@
         
+)
 ))); // 

Update problem 632