Summary Ranges Problem
Summary Ranges Problem — ExecCode Easy DSA Practice
Solve the Summary Ranges problem on ExecCode. Free online easy DSA practice in Intervals. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given a sorted array of unique integers, return the smallest sorted list of ranges that together exactly cover every number in the array, formatting each range as "a->b" or just "a" when it spans a single number.
Examples
Input nums = [0, 1, 2, 4, 5, 7]; Output ["0->2", "4->5", "7"]. Input nums = [0, 2, 3, 4, 6, 8, 9]; Output ["0", "2->4", "6", "8->9"]. Input nums = []; Output []
Constraints
0 ≤ nums.length ≤ 20 -2³¹ ≤ nums[i] ≤ 2³¹ - 1 all values of nums are unique nums is sorted in ascending order
Practice Summary Ranges free on ExecCode. Browse DSA problems, topic map, and placement guides.