Created
April 3, 2020 22:31
-
-
Save asa55/ebe20c33f32b05ac0d8fa08b9e07b6b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How do you check if two strings are anagrams of each other? | |
#include <iostream> | |
#include <string> | |
#include <algorithm> | |
std::string ana = "cinema"; | |
std::string gram = "iceman"; | |
int main () | |
{ | |
std::sort(ana.begin(), ana.end()); //if this | |
std::sort(gram.begin(), gram.end()); //equals this | |
std::cout << (ana == gram) << std::endl;//we're good | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment