Sort 101 Discussions, By:
Please Login in order to post a comment
Thanks for including the video link to the MIT lecture.
Tabulated Method Solution
Is there any way to report this problem ? It's checker doesnt work. I have correct code and it fails on even first test case and they are the same.
same problem in every other machine it gives right answer even in online editior also....Were you able to fix it?
@puneetrajraipur1 and @rakitamiljan
i to face same problem;
when i use System.out.println(ans); it do not pass any case
even if String ans="1 2 3";
i use System.out.print(ans); it pass all test cases//with logical ans
1) do not have extra space at the end
2) do not start new line after printing ans (or no [\n] after ans)
([----] is for new data/char)
hope this help or let me know if any doubt
i am getting correct output in sample case as 3 4 1
but getting some command error as
Error in command /custom-RB1ptiIaeNCmJhh5eUdH/solution
errno = 2
You might have added space after last printed digit as well.
Could someone say me why I have this error, please?:
though the output is same but compilation message shows wrong answer and what is custom checker error message it shows:
Error in command /custom-KY8ZmYAHCVNTfclUPusO/solution
errno = 2
Python 3 solution, using dynamic program with a two dimensional table the size of the input arrays to store the length of longest subsequence, then trace back from the last square in the table to see where the matches where and eventually print all these matches (reversed) - that's the longest subsequence
a =  + [int(x) for x in input().split()] # to make first row/col of 0's
b =  + [int(x) for x in input().split()]
# table will be the dynamic programming table
table = [[0 for _ in range(len(a))] for _ in range(len(b))]
# populating table
for i in range(1,len(b)):
for j in range(1,len(a)):
if a[j] == b[i]:
table[i][j] = table[i-1][j-1] + 1
table[i][j] = max(table[i][j-1], table[i-1][j])
# table[len(b)-1][len(a)-1] is the length of longest common subsequence
# in order to find the subsequence we have to trace back from that square
# see where the matches where and add them to word common_subsequence
length = table[len(b)-1][len(a)-1]
common_subsequence = 
curr = len(b)-1,len(a)-1 # save my current index in table in the search
if b[curr] == a[curr]: # match - belongs to common subseq
length -= 1
curr = (curr-1,curr-1)
else: # go to the square that has longer subsequence until now
if table[curr-1][curr] > table[curr][curr-1]:
curr = (curr-1,curr)
curr = (curr,curr-1)
print(' '.join(str(x) for x in common_subsequence[::-1])) # reverse
Looks like there is some issue with this test case, Please fix the backend checker.
I have similar problem as @nesamani and others.
showing wrong answer for 1 2 3 for the sample test case , for the case 2 my output is 3 9 9 9 7 0 which is one of the longest sequence but it is only checking (3 3 9 9 7 0) (second test case - 9 10
3 9 8 3 9 7 9 7 0
3 3 9 9 9 1 7 2 0 6
The checker is still not yet fixed :-/
The problem description says Sample Output is 1 2 3. Although my program outputs 1 2 3 it still can't pass the test.
1 2 3
I tried removing the tailing newline character but still no luck. Perhaps the checker does not work?
Boys, there is some problem with the solution checker, it does not accept valid outputs. Please check it!
During "Run code" I get the following in "Custom Checker Error Message" field:
Error in command /custom-ZLzyY9MbLvo731KOX9bk/solution
errno = 2
Also all tests fails.
Ya, I am also getting the same error. Were you able to fix it?
I know what you did there :) GB GB GB :P
i'm also getting the some error like