Skip to content

Instantly share code, notes, and snippets.

@samikshapgaikwad
Created June 12, 2025 18:03
Show Gist options
  • Save samikshapgaikwad/86492da40d1bb07fd464781d5c438d53 to your computer and use it in GitHub Desktop.
Save samikshapgaikwad/86492da40d1bb07fd464781d5c438d53 to your computer and use it in GitHub Desktop.
class Solution {
public:
bool isAnagram(string s, string t) {
if (s.size() != t.size()) return false;
unordered_map<char, int> mp;
for (int i = 0; i < s.size(); i++) {
mp[s[i]]++;
mp[t[i]]--;
}
for (auto x : mp) {
if (x.second != 0) return false;
}
return true;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment