day22笔记
1.题目描述
2.代码构思(debug)
class Solution:
def summaryRanges(self, nums: List[int]) -> List[str]:
if not nums:
return nums
ret = []
i = 0
len1 = len(nums)
while (i < len1):
low = i
i += 1
while i < len1 and nums[i] == nums[i - 1] + 1:
i += 1
high = i - 1
temp = str(nums[low])
if (low < high):
temp += "->"
temp += str(nums[high])
ret.append(temp)
return ret