An anagram is a word formed by rearranging the letters of another word. The words “listen” and "sile…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
There Should be a test case like “code and codp”. When I first solved this problem I noticed that my program has issue for that type of input. But the submission showed that my code passed all the tests.
I know. The correct solution will print “No” in that case. What I’m saying is If I have a problem in my code that can’t print “No” in the specified case, and then If I submit my code, toph accepts my code and says "all test cases passed ". I hope you got what I’m trying to say.
Thank you @Galib.603386 for pointing this out. The dataset didn’t really have any equal length strings in them that were not anagrams.
A new test case has been added.
It seems both of your recent submissions for this problem now fail. However, we usually do not update the verdict of a submission that has already been accepted (as a sort of extension of the similar ICPC rule).
You can retry the problem and try to solve it again.
It’s great that you are really checking what I’m saying. As you told, now I got stuck in the problem. I don’t get it. For which input my solution fails? Can you please tell me what’s wrong in my code?
#include<stdio.h>
#include<string.h>
int main()
{
char a[100],b[100];
scanf("%s",a);
scanf("%s",b);
int L1=strlen(a);
int L2=strlen(b);
int i,j,n=0;
if(L1==L2){
for(j=0;j<L1;j++){
for(i=0;i<L1;i++){
if(a[j]==b[i]){
b[i]=0;
n++;
}
}
}
if(n==L1){
printf("Yes\n");
}
else{
printf("No\n");
}
}
else{
printf("No\n");
}
return 0;
}