标签:end ref solution summary break str bre pre targe
1 class Solution: 2 def summaryRanges(self, nums: List[int]) -> List[str]: 3 left,right,lens,ans = 0,0,len(nums),[] 4 while left < lens: 5 right = left 6 while right < lens: 7 if right == left or nums[right] == nums[right - 1] + 1: 8 right += 1 9 else:break 10 if right - 1 > left: 11 ans.append(str(nums[left]) + ‘->‘ + str(nums[right-1])) 12 else: 13 ans.append(str(nums[left])) 14 left = right 15 return ans
标签:end ref solution summary break str bre pre targe
原文地址:https://www.cnblogs.com/lj95/p/14395753.html