public List<String> findMissingRanges(int[] nums, int lower, int upper) {
        List<String> res = new ArrayList<String>();
        if (nums == null) return res;

        if (nums.length == 0) {
            res.add(makeRange(lower, upper));
            return res;
        }

        int n = nums.length - 1;
        if (lower < nums[0]) res.add(makeRange(lower, nums[0] - 1));
        for (int i = 1; i <= n; ++i) {
            if (nums[i] != nums[i - 1] + 1) {
                res.add(makeRange(nums[i - 1] + 1, nums[i] - 1));
            }
        }
        if (upper > nums[n]) res.add(makeRange(nums[n] + 1, upper));
        return res;
    }