+ 1

Plz tell what wrong in the code.Its the python code for calculating the length of longest increasing subsequence from a list.

https://code.sololearn.com/cK4o2TA3P83s/?ref=app

29th Mar 2020, 9:39 AM
ayush verma
ayush verma - avatar
10 Respostas
+ 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.
29th Mar 2020, 4:46 PM
Lothar
Lothar - avatar
+ 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.
29th Mar 2020, 10:50 AM
Lothar
Lothar - avatar
+ 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?
29th Mar 2020, 12:28 PM
Lothar
Lothar - avatar
+ 3
Ok, in the meantime i found something to read about it, and i got it now
29th Mar 2020, 1:20 PM
Lothar
Lothar - avatar
+ 1
So can you please explain why the result is no output
29th Mar 2020, 1:36 PM
ayush verma
ayush verma - avatar
+ 1
Thanks....I got the error!
29th Mar 2020, 5:04 PM
ayush verma
ayush verma - avatar
0
I have the updated the question.
29th Mar 2020, 10:58 AM
ayush verma
ayush verma - avatar
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.
29th Mar 2020, 12:50 PM
ayush verma
ayush verma - avatar
0
List(a) at The Last line , i put these în your code and The output îs 6
30th Mar 2020, 11:08 AM
Stefan Horga
Stefan Horga - avatar
0
Sorry list(a) wit l not L 😙
30th Mar 2020, 11:09 AM
Stefan Horga
Stefan Horga - avatar