classSolution(object): deflengthOfLIS(self, nums): """ :type nums: List[int] :rtype: int """ length = len(nums) if length < 2: return length tail = [nums[0]] for num in nums[1:]: if num > tail[-1]: tail.append(num) continue left, right = 0, len(tail) - 1 while left < right: mid = (left + right) >> 1 if tail[mid] < num: left = mid + 1 else: right = mid tail[left] = num returnlen(tail)