Skip to content

Commit

Permalink
[CPP] 242. Valid Anagram
Browse files Browse the repository at this point in the history
  • Loading branch information
UnresolvedCold committed Apr 3, 2022
1 parent e4fdeeb commit d9aa752
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cpp/242-Valid-Anagram.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution {
public:
bool isAnagram(string s, string t) {
vector<int> count(26, 0);
for (auto a: s) count[a-'a']++;
for (auto a: t) count[a-'a']--;
for (auto c: count) if(c) return false;
return true;
}
};

0 comments on commit d9aa752

Please sign in to comment.