Skip to content

Instantly share code, notes, and snippets.

@lectricas
Created March 23, 2021 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lectricas/e0974f8ba16fa299f662425808c09d22 to your computer and use it in GitHub Desktop.
Save lectricas/e0974f8ba16fa299f662425808c09d22 to your computer and use it in GitHub Desktop.
int main() {
std::string st1, st2;
getline(std::cin, st1);
getline(std::cin, st2);
std::unordered_map<char, char> map;
if (st1.length() != st2.length()) {
std::cout << "NO";
return 0;
}
for (int i = 0; i < st1.length(); i++) {
if (map.find(st1[i]) != map.end()) {
if (map[st1[i]] != st2[i]) {
std::cout << "NO";
return 0;
}
} else {
map[st1[i]] = st2[i];
}
}
std::cout << "YES";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment