@@ -0,0 +1,1092 @@
+/***%0A * Given a sorted integer array where the range of elements are %5Blower, upper%5D inclusive, %0A * return its missing ranges.%0A *%0A * For example, given %5B0, 1, 3, 50, 75%5D, lower = 0 and upper = 99, %0A * return %5B%222%22, %224-%3E49%22, %2251-%3E74%22, %2276-%3E99%22%5D. %0A */%0A%0Apublic class MissingRanges%7B%0A    List%3CString%3E findMissingRanges(int A%5B%5D, int lower, int upper) %7B%0A        List%3CString%3E ret = new ArrayList%3CString%3E();%0A        int prev = lower - 1;%0A        for (int i = 0; i %3C A.length && A%5Bi%5D %3C upper + 1; i++) %7B%0A            if (prev %3C A%5Bi%5D && prev + 1 != A%5Bi%5D) %7B%0A                ret.add(makeRange(prev, A%5Bi%5D));%0A                prev = A%5Bi%5D;%0A            %7D else%0A                prev = A%5Bi%5D;%0A        %7D%0A        ret.add(makeRange(prev, upper + 1));%0A%0A        return ret;%0A    %7D%0A%0A    String makeRange(int lower, int upper) %7B%0A        StringBuilder sb = new StringBuilder();%0A        if (lower + 1 == upper - 1)%0A            sb.append('0' + lower + 1);%0A        else %7B%0A            sb.append('0' + lower + 1);%0A            sb.append(%22-%3E%22);%0A            sb.append('0' + upper - 1);%0A        %7D%0A        return sb.toString();%0A    %7D%0A%7D%0A

add MissingRanges.java