Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool is_permutation(const std::string& s1, const std::string& s2) {
- std::map<char, int64_t> letters{};
- for(auto letter: s1)
- ++letters[letter];
- for(auto letter: s2)
- --letters[letter];
- return std::all_of(letters.begin(), letters.end(), [](const auto& pair) {
- return pair.second == 0;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment