class Solution:
def longestConsecutive(self, nums: 'List[int]') -> int:
if len(nums)<=1:
return len(nums) nums2 = sorted(set(nums))
pre = nums2[0]
maxc = 0
curc = 1
for i in range(1,len(nums2)):
if nums2[i] == pre + 1:
curc += 1
else:
maxc = max(maxc,curc)
curc = 1
pre = nums2[i]
return max(maxc,curc)