Search⌘ K
AI Features

Solution: Summary Ranges

C# solution for the Summary Ranges problem using the Knowing What to Track pattern.

Statement

Given a sorted integer array nums with all distinct values, return the smallest list of ranges that exactly covers every number in nums.

A range represents a maximal consecutive sequence of integers in nums. For each such sequence:
If the sequence contains exactly one number x, output the string "x".
Otherwise, if the sequence starts at a and ends at b, output the string "a->b".

Return the ranges in the same order as they appear in nums.

Constraints:

  • 00 \leq ...