Giving Invalid submission even after the expected returned value is matched! Is it just me?


#1

My code is returning the expected value, still, it shows invalid submission. If anyone else has ever encountered such a case on this platform before, please let me know what to do now. (I am not printing any values inside my function.)


#2

I am facing the same problem!!


#3


#4

Actually here what is happening:
Let say I access a particular string in array A as A[i], where i is the index. Now let say A[i] is “abcd”. Now when you will call A[i].size() function, then it will return value 4 only, but if I will try to access the 5th or further characters beyond 5 (A[i][5] or A[i][6] and so on…), then it will not give you an error. It will return you a NULL object(you can consider it an empty string but of length 1).
So somewhere in your code, you are accessing such an empty string and appending it to your main answer due to which it seems that your output is right, but actually, it has some extra unseen stuff also.


#5

I am also getting same error. As I have tried compiling it on codechef compiler, it is running without any error for the below inputs.
17 “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” “aaaa” "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


#6

Hi, I faced the same problem then I tried to run the code on leetcode, and in my case the error of the above aaaaaaaaaa test case was extra space after "aa ". The error in my code was, as I was checking the lcs from 0 to length of string but the length should not be included, what I mean is it should be i<n not i<=n .