Remove number from set consecutively, a dry python code
class Solution:\n    # @param num, a list of integer\n    # @return an integer\n    def longestConsecutive(self, num):\n        numbers = set(num)\n        max_
    class Solution:\n    # @param num, a list of integer\n    # @return an integer\n    def longestConsecutive(self, num):\n        numbers = set(num)\n        max_len = 0\n        while numbers:\n            m = n = numbers.pop()\n            length = 1\n            while m-1 in numbers:\n                numbers.remove(m-1)\n                m -= 1\n                length += 1\n            while n+1 in numbers:\n                numbers.remove(n+1)\n                n += 1\n                length += 1\n            max_len = max(max_len, length)\n        return max_len\n\nkeep trace of the max_len
[]