给定一个排序的整数数组 nums
,其中元素的范围在 闭区间 [lower, upper]
当中,返回不包含在数组中的缺失区间。
示例1:
输入: nums = [0, 1, 3, 50, 75], lower = 0 和 upper = 99,
输出: [“2”, “4->49”, “51->74”, “76->99”]
解释:区间为:
[2,2] --> "2"
[4,49] --> "4->49"
[51,74] --> "51->74"
[76,99] --> "76->99"
示例2:
输入:nums = [], lower = 1, upper = 1
输出:["1"]
解释:唯一缺失的区间是 [1,1],也就是 "1"
示例3:
输入:nums = [], lower = -3, upper = -1
输出:["-3->-1"]
示例4:
输入:nums = [-1], lower = -1, upper = -1
输出:[]
示例5:
输入:nums = [-1], lower = -2,