Practice Summary Ranges
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given the sorted array nums of distinct integers, group consecutive values into the fewest possible inclusive ranges. The ranges must be sorted and cover exactly the input values, with no gaps included and no value covered twice. Represent a range from a to b as "a->b" when a and b differ; represent a single value as "a". Return the list of these strings.
Source: Summary Ranges on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [0,1,2,4,5,7]
["0->2","4->5","7"]
# Example 2
nums = [0,2,3,4,6,8,9]
["0","2->4","6","8->9"]
Constraints
Related LeetCode Problems
Practice more problems similar to Summary Ranges.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.