Compare commits
No commits in common. "58b85d23dd93e794449a2a28ecde08f35561b4b0" and "9dea34d7ac17ca6276406682cb9c1b0aaee4de79" have entirely different histories.
58b85d23dd
...
9dea34d7ac
@ -1,13 +0,0 @@
|
|||||||
def llongest_increasing_subsequence(arr: list) -> list:
|
|
||||||
if not arr:
|
|
||||||
return []
|
|
||||||
dp = [[x] for x in arr]
|
|
||||||
for i in range(len(arr)):
|
|
||||||
for j in range(i):
|
|
||||||
if arr[j] < arr[i] and len(dp[j]) + 1 > len(dp[i]):
|
|
||||||
dp[i] = dp[j] + [arr[i]]
|
|
||||||
return max(dp, key = len)
|
|
||||||
|
|
||||||
print(dp)
|
|
||||||
if __name__ == "__main__":
|
|
||||||
print(f"llongest_increasing_subsequence([10, 9, 2, 5, 3, 7, 101, 18] -> {llongest_increasing_subsequence([10, 9, 2, 5, 3, 7, 101, 18])}")
|
|
||||||
Loading…
Reference in New Issue
Block a user