Skip to content

Commit d890103

Browse files
authoredDec 26, 2021
Create 300-Longest-Increasing-Subsequence.py
1 parent 27d5af9 commit d890103

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎300-Longest-Increasing-Subsequence.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def lengthOfLIS(self, nums: List[int]) -> int:
3+
LIS = [1] * len(nums)
4+
5+
for i in range(len(nums) - 1, -1, -1):
6+
for j in range(i + 1, len(nums)):
7+
if nums[i] < nums[j]:
8+
LIS[i] = max(LIS[i], 1 + LIS[j])
9+
return max(LIS)

0 commit comments

Comments
 (0)