My issue
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
// int t;cin>>t;
// while(t--){
string X,Y;
cin>>X>>Y;
sort(X.begin(),X.end());
sort(Y.begin(),Y.end());
if(X==Y){
cout<<"Anagram"<<endl;
}
else{
cout<<"Not Anagram"<<endl;
}
// }
return 0;
}
Problem Link: TIC01 Problem - CodeChef
One possible problem might be ‘case’ of letters in strings being different. In the given sample example;
Leonardo Da Vinci
O Draconian Devil
It is an Anagram but the code fails as the program cannot differentiate between the upper and the lower case letters having no difference for our use in this problem.
I suppose we need to convert all letters in same case then check if the strings match or not.