Given an integer array nums, return the length of the longest strictly increasing subsequence.
def length_of_lis(nums: List[int]) -> int: if not nums: return 0 max_length = [1] * len(nums) for i in range(1, len(nums)): for j in range(i): if nums[i] > nums[j]: max_length[i] = max(max_length[i], max_length[j] + 1) return max(max_length)
from bisect import bisect_left def length_of_lis(nums: List[int]) -> int: if not nums: return 0 tails = [] for num in nums: pos = bisect_left(tails, num) if pos == len(tails): tails.append(num) else: tails[pos] = num return len(tails)