Compress a sorted list of integers into compact range strings.
You are given a sorted array of integers with no duplicates. Group consecutive values into ranges and represent each range as a string.
start->end.Return the list of range strings in the same order as the numbers appear.
nums.nums is sorted in strictly increasing order.nums.nums is sorted in strictly increasing order.Example 1
Input
nums = [0,1,2,4,5,7]
Output
["0->2","4->5","7"]
Explanation
The consecutive groups are [0,1,2], [4,5], and [7].
Example 2
Input
nums = [0,2,3,4,6,8,9]
Output
["0","2->4","6","8->9"]
Explanation
Only adjacent numbers are merged into a range.
Example 3
Input
nums = []
Output
[]
Explanation
An empty array produces no ranges.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.