diff --git a/编程题/阿里/300-最长递增子序列.py b/编程题/阿里/300-最长递增子序列.py new file mode 100644 index 0000000..1e15ce4 --- /dev/null +++ b/编程题/阿里/300-最长递增子序列.py @@ -0,0 +1,13 @@ +from bisect import bisect_left +class Solution: + def lengthOfLIS(self, nums: List[int]) -> int: + + long_sub_set =[nums[0]] + for i in range(1,len(nums)): + if nums[i]>long_sub_set[-1]: + long_sub_set.append(nums[i]) + else: + index = bisect_left(long_sub_set,nums[i]) + long_sub_set[index] = nums[i] + + return len(long_sub_set) \ No newline at end of file diff --git a/编程题/阿里/readme.md b/编程题/阿里/readme.md new file mode 100644 index 0000000..7fb3014 --- /dev/null +++ b/编程题/阿里/readme.md @@ -0,0 +1 @@ +Tip :300-中等--最长递增子序列是子集中的一部分 \ No newline at end of file