classSolution: deflongestConsecutive(self, nums: List[int]) -> int: if nums == []: return0 new_list = sorted(set(nums)) ans = 1 longest = 1 # print(new_list) for i inrange(0, len(new_list)-1): if new_list[i+1] == new_list[i] + 1: ans += 1 if ans >= longest: longest = ans continue ans = 1 return longest