You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dynamic_programming/longest_increasing_subsequence.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,8 @@ def longestSub(ARRAY): #This function is recursive
16
16
#Else
17
17
PIVOT=ARRAY[0]
18
18
LONGEST_SUB=[] #This array will contains the longest increasing sub array
19
-
foriinrange(1,ARRAY_LENGTH):
20
-
if (ARRAY[i] <PIVOT): #For each element from the array (except the pivot), if the element is smaller than the pivot, it won't figure on the sub array that contains the pivot
19
+
foriinrange(1,ARRAY_LENGTH):#For each element from the array (except the pivot),
20
+
if (ARRAY[i] <PIVOT): #if the element is smaller than the pivot, it won't figure on the sub array that contains the pivot
21
21
TEMPORARY_ARRAY= [ elementforelementinARRAY[i:] ifelement>=ARRAY[i] ] #But it cas figure in an increasing sub array starting from this element
22
22
TEMPORARY_ARRAY=longestSub(TEMPORARY_ARRAY) #We calculate the longest sub array that starts from this element
23
23
if ( len(TEMPORARY_ARRAY) >len(LONGEST_SUB) ): #And we save the longest sub array that begins from an element smaller than the pivot (in LONGEST_SUB)
0 commit comments