You are given a sorted unique integer array nums. A range [a,b] is the set of all integers from a to b (inclusive). Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such that x is in one of the ranges but not in nums. Each range [a,b] in the list should be output as: - "a->b" if a != b - "a" if a == b
Example 1
Input: nums = [0,1,2,4,5,7]
Output: ["0->2","4->5","7"]
Explanation: 0, 1, 2 are consecutive, so they form "0->2". 4 and 5 form "4->5". 7 stands alone as "7".
Example 2
Input: nums = [0,2,3,4,6,8,9]
Output: ["0","2->4","6","8->9"]
Explanation: 0 stands alone, 2-3-4 is a run ("2->4"), 6 stands alone and 8-9 is a run ("8->9").
Example 3
Input: nums = [1]
Output: ["1"]
Explanation: A single number forms a single range, "1".
Because the array is sorted, consecutive numbers form a run. Walk once: extend the current run while each next number is exactly one more than the last, then emit the run as either 'start' or 'start->end'.
Run checks all cases above. Submit evaluates all test cases.