fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int t;// number of testcases
  5. cin>>t;
  6. while(t--){
  7. string str1,str2;// two strings of equal length str1 and str2
  8. cin>>str1>>str2;
  9. unordered_multiset<char> s1,s2;// two sets
  10. for(int i=0;i<str1.length();i++){
  11. s1.insert(str1[i]);// initialization
  12. s2.insert(str2[i]);
  13. }
  14. unordered_multiset<char>::iterator itr;
  15. for(itr=s1.begin();itr!=s1.end();itr++){
  16. if(s2.find(*itr)!=s2.end()) s2.erase(itr);/*if *itr is present in s2 then delete its address .....
  17.   i know i am making mistake somewhere here but i can't figure out*/
  18. else {
  19. cout<<"NO"<<"\n";// print NO if not found
  20. break;
  21. }
  22. }
  23. if(itr==s1.end()) cout<<"YES"<<"\n";// if itr reached the end print YES
  24. }
  25. }
Runtime error #stdin #stdout 0s 15240KB
stdin
1
asdasd asdsad
stdout
Standard output is empty