def longestsub(self,nums):
    nums = set(nums)
    length = 0
    for x in nums:
        if x-1 not in nums:
            y = x+1
            while y in nums:
                y += 1
            best = max(best,y-x)
    return best