163. Missing Ranges

Given a sorted integer array where the range of elements are in the inclusive range [lower, upper], return its missing ranges.

For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, return ["2", "4->49", "51->74", "76->99"].

一刷
题解:如果当前值与lower相等,那么lower和i都要自加,找到下一个缺失的。比如lower=1, nums = {1,2,3}, 缺失的为4

public class Solution {
    public List findMissingRanges(int[] nums, int lower, int upper) {
        List res = new ArrayList<>();
        if(nums.length==0){
            res.add(getRange(lower, upper));
            return res;
        }
        
        int next = lower;
        
        for(int i=0; i%d", a, b);
    }
}

你可能感兴趣的:(163. Missing Ranges)