+ 1
Plz tell what wrong in the code.Its the python code for calculating the length of longest increasing subsequence from a list.
10 Réponses
+ 6
There are 2 while loops running. In the second iteration, the program will stay in the inner loop as an infinite loop. As the execution time is limited in playground, it shows the message "no output.
+ 3
What do you mean by "longest subsequence"? Is it the length of a number (in digits), or is it the highest value from the list? It would be great if you could give us the expected output from this code.
+ 3
You mentioned, that the longest increasing subsequece should be 6. May be your definition of "longest increasing subsequence" is different from my version. This is the original list a used in the code:
a=[1,2,9,4,7,3,11,8,14,6]
If i print a sorted version of your list "a", it looks like this:
[1, 2, 3, 4, 6, 7, 8, 9, 11, 14]
So for me the longest increasing subsequence is: 1,2,3,4 or 6,7,8,9. What do you think?
+ 3
Ok, in the meantime i found something to read about it, and i got it now
+ 1
So can you please explain why the result is no output
+ 1
Thanks....I got the error!
0
I have the updated the question.
0
By longest increasing subsequence I mean
If a =[1,2,9,4,7,3,11,8,14,6]
So longest increasing subsequence is [1,2,4,7,11,14] whose length is 6.
there can be more than one possible list
but in this case it is only one which is the longest.
0
List(a) at The Last line , i put these în your code and The output îs 6
0
Sorry
list(a) wit l not L 😙