Skip to content

Instantly share code, notes, and snippets.

@asa55
Created April 3, 2020 22:31
Show Gist options
  • Save asa55/ebe20c33f32b05ac0d8fa08b9e07b6b5 to your computer and use it in GitHub Desktop.
Save asa55/ebe20c33f32b05ac0d8fa08b9e07b6b5 to your computer and use it in GitHub Desktop.
// 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