[OFFICIAL] Live DSA Learning Session 2 - Contest 1 - Part 2

heyy can someone please tell how to join whatsapp group?? i’m not albe to join the group.

anyone please help me in this question :CodeChef: Practical coding for everyone

I am getting correct answer in sample but WA when submitted

here my solution :slight_smile:

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
int t;
cin>>t;
while(t–){
string m,w;
cin>>m>>w;
sort(m.begin(),m.end());
sort(w.begin(),w.end());
bool cond = false;
if(m.length()>w.length()){
for(int i=0;i<m.length()-w.length();i++){
if(w.compare(m.substr(i,i+w.length()))){
cout<<“YES”<<endl;
cond = true;
break;
}
}
if(!cond)cout<<“NO”<<endl;
}
else if(m.length()<w.length()){
for(int i=0;i<w.length()-m.length();i++){
if(m.compare(w.substr(i,i+m.length()))){
cout<<“YES”<<endl;
cond = true;
break;
}
}
if(!cond)cout<<“NO”<<endl;
}
else{
for(int i=0;i<m.length();i++){
if(m[i]!=w[i]){
cond= true;
cout<<“NO”<<endl;
}
}
if(!cond){
cout<<“YES”<<endl;
}
}
}
return 0;
}