fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool a(string s,string t){
  4. if(s.size()!=t.size()) return false;
  5. unordered_map<char,int>m;
  6. for(int i=0;i<s.size();i++){
  7. m[s[i]]++;
  8. m[t[i]]--;
  9. }
  10. for(auto& x:m){
  11. if(x.second!=0) return false;
  12. }
  13. return true;
  14. }
  15. int main(){
  16. string s="listen",t="silent";
  17. cout<<(a(s,t)?"y":"no")<<"\n";
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
y