I am getting wrong answer when I submit.Can anyone please point out the mistake I am making?
Here is my solution:
I am getting wrong answer when I submit.Can anyone please point out the mistake I am making?
Here is my solution:
Try this testcase
1
5
1 2 4 2 3
3
1 2 3
Answer is no but your code gives yes
My code gives Yes in my system!
f should be there in s as a substring but you are checking for subsequence.
This problem statement is one of the worst problems in terms of clarity.
My AC code used this logic-
for(j=0;j<f;j++)
{
for(i=0;i<n;i++)
{
if(arr[i]==fav[j])
{
flag++;
break;
}
}
Meaning, if a= (3 2 1 1 2} and f = {1 2 3}, the answer should be yes. Try re-writing the code with this in mind. Meaning, order isnt important, it should just have those elements. This ought to be explained via Sample Input Output as this was not stressed at all in the statement.
Thanks.I thought that the order mattered.