Maximal Consecutive Number Ranges
Problem statement
nums is strictly increasing. Return every maximal consecutive range in order. Format a multi-value range as start->end and a singleton as its value.
Function
consecutiveRanges(nums: int[]) → String[]Examples
Example 1
nums = [-1,0,1,2,5,6,8]return = ["-1->2","5->6","8"]There are two multi-value runs and one singleton.
Constraints
0 <= nums.length <= 10^5.- Values are unique and strictly increasing.