Python with sets  ||  12 lines, sets  ||   T/S : 99% / 99%
Here\'s the plan:\n\n- We change the nums to a set, pop one number n from the set.\n\n- We count how many consecutive numbers are to the left, and to the right 
Here\'s the plan:\n\n- We change the nums to a set, pop one number `n` from the set.\n\n- We count how many consecutive numbers are to the left, and to the right as well, removing the numbers from the set as we go.\n- We compare the length of the sequence to previous sequences and . \n- We quit when the remaining numbers are too few to form a maximum sequence, we return the crrent maximum sequence.\n```\nclass Solution:\n    def longestConsecutive(self, nums: list[int]) -> int:\n        mx, numSet = 0, set(nums)\n\n        while len(numSet) > mx:     # grab a number at random\n            n = numSet.pop()\n            l, r = n-1, n+1\n            \n            while l in numSet:      # find those to the left in the seq\n                numSet.remove(l)\n                l-= 1\n                \n            while r in numSet:      # find those to the right in the seq\n                numSet.remove(r)\n                r+= 1\n\n            mx = max(mx, r-l-1)     # see whether this seq is our winner\n \n        return mx                   # return the winner\n```\n[https://leetcode.com/problems/longest-consecutive-sequence/submissions/643048905/](https://leetcode.com/problems/longest-consecutive-sequence/submissions/643048905/)\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*), in which *N* ~ `len(nums)`.
['Ordered Set', 'Python']