Ilya_Bykonya

Untitled

May 28th, 2024
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | Source Code | 0 0
  1. bool is_permutation(const std::string& s1, const std::string& s2) {
  2.     std::map<char, int64_t> letters{};
  3.     for(auto letter: s1)
  4.         ++letters[letter];
  5.     for(auto letter: s2)
  6.         --letters[letter];
  7.     return std::all_of(letters.begin(), letters.end(), [](const auto& pair) {
  8.         return pair.second == 0;
  9.     });
  10. }
  11.  
Advertisement
Add Comment
Please, Sign In to add comment