File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed
leetcode_python_solutions Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change 11class Solution :
2+ """
3+ Longest Increasing Subsequence
4+
5+ dp[i] denotes the length of the LIS ends with nums[i]
6+
7+ dp[i] = max(dp[i], 1 + dp[j]) for j < i if dp[i] > dp[j]
8+
9+
10+ """
211 def lengthOfLIS (self , nums : List [int ]) -> int :
312 n = len (nums )
413 dp = [1 ]* n
@@ -8,12 +17,17 @@ def lengthOfLIS(self, nums: List[int]) -> int:
817 dp [i ] = max (dp [i ], 1 + dp [j ])
918 return max (dp )
1019
11- """
12- Longest Increasing Subsequence
13-
14- dp[i] denotes the length of the LIS from nums[0:i+1]
15-
16- dp[i] = max(1 + dp[j]) for j < i if dp[i] > dp[j]
17-
1820
19- """
21+ # import bisect
22+ #
23+ # class Solution:
24+ # def lengthOfLIS(self, nums: List[int]) -> int:
25+ # # dp[i] is the smallest ending number of the LISs with length i+1
26+ # dp = []
27+ # for num in nums:
28+ # index = bisect.bisect_left(dp, num)
29+ # if index == len(dp):
30+ # dp.append(num)
31+ # else:
32+ # dp[index] = num
33+ # return len(dp)
You can’t perform that action at this time.
0 commit comments