Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Anagrams
//Title of this code #include <iostream> #include <map> #include <string> using namespace std; bool areAnagrams(const string& s1, const string& s2) { if (s1.length() != s2.length()) return false; map<char, int> m; for (int i = 0; i < s1.length(); ++i) { if (m.find(s1[i]) == m.end()) m[s1[i]] = 1; else ++m[s1[i]]; if (m.find(s2[i]) == m.end()) m[s2[i]] = -1; else --m[s2[i]]; } typename map<char, int>::iterator it; for (it = m.begin(); it != m.end(); ++it) if (it->second > 0) return false; return true; } int main() { std::cout << areAnagrams("abac","baca"); }
run
|
edit
|
history
|
help
0
C++ Solar eclipse program(Shoushi integrated) 1568 - 1644 also check Lunar eclipse for Xing Yunlu
NameTempSpecial2
Counting top students
template
Изволов#7
Simulare 2022
LP
My billing system
Dar
Bank System