Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges.
(将数组中连续的范围合并)
Example:

1. 设置标志位 left
具体实现过程如下:
1 | class Solution: |
2. 直接统计range
在遍历数组的过程中不断地更新统计中range的右界,具体实现过程如下:
1 | def summaryRanges(self, nums): |
Given a sorted integer array without duplicates, return the summary of its ranges.
(将数组中连续的范围合并)
Example:
具体实现过程如下:
1 | class Solution: |
在遍历数组的过程中不断地更新统计中range的右界,具体实现过程如下:
1 | def summaryRanges(self, nums): |