Skip to content

Commit 6779f87

Browse files
[CPP] 242. Valid Anagram
1 parent 919aecc commit 6779f87

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cpp/242-Valid-Anagram.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public:
3+
bool isAnagram(string s, string t) {
4+
vector<int> count(26, 0);
5+
for (auto a: s) count[a-'a']++;
6+
for (auto a: t) count[a-'a']--;
7+
for (auto c: count) if(c) return false;
8+
return true;
9+
}
10+
};

0 commit comments

Comments
 (0)