228. Summary Ranges

Given a sorted integer array without duplicates, return the summary of its ranges.

For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].

一刷

public class Solution {
    public List summaryRanges(int[] nums) {
        List res = new ArrayList<>();
        if(nums == null || nums.length==0) return res;
        
        int left = nums[0], next = left+1;
        for(int i=1; i");
        sb.append(b);
        return sb.toString();
    }
}

你可能感兴趣的:(228. Summary Ranges)