题目:
题解:
func summaryRanges(nums []int) (ans []string) {for i, n := 0, len(nums); i < n; {left := ifor i++; i < n && nums[i-1]+1 == nums[i]; i++ {}s := strconv.Itoa(nums[left])if left < i-1 {s += "->" + strconv.Itoa(nums[i-1])}ans = append(ans, s)}return
}