LeetCode --- 228. Summary Ranges 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 228. Summary Ranges 解题报告相关的知识,希望对你有一定的参考价值。

You are given a sorted unique integer array nums.

Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such that x is in one of the ranges but not in nums.

Each range [a,b] in the list should be output as:

  • "a->b" if a != b
  • "a" if a == b

Example 1:

Input: nums = [0,1,2,4,5,7]
Output: ["0->2","4->5","7"]
Explanation: The ranges are:
[0,2] --> "0->2"
[4,5] --> "4->5"
[7,7] --> "7"

Example 2:

<

以上是关于LeetCode --- 228. Summary Ranges 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

Leetcode 228: Summary Ranges

LeetCode --- 228. Summary Ranges 解题报告

#Leetcode# 228. Summary Ranges

leetcode-Summary Ranges-228

228. Summary Ranges

228. Summary Ranges