What's wrong with this CODE (NOTINCOM) ?

Here is my code: https://www.codechef.com/viewsolution/15529803
The expected output is also produced. The output format is also correct. Please help me with the code.
Thanks a lot!

Please help me out with this code!

Your approach fails if array has values with more than 1 digit.

Say your first array is {1,3} and second is {12,13}. Second Array is taken as string, so its β€œ1213”. Now, β€œ1213”.contains(1) is true, because string has β€œ1” . Thats the error in your implementation :slight_smile:

1 Like

@arnavvarshney

if(berta.contains(alexNumbers[j]))

This would fail as @vijju123 said.

Better scan the numbers separately and maintain a hashmap or similar data structure(for faster search in this case) of first array and search the no.s from second array in this DS.

Here’s the link to my code.

1 Like