Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool isAnagram(string s, string t) {
- if (s.size() != t.size()) {
- return false;
- }
- int count1[26] = {0}, count2[26] = {0};
- for (int i=0; i<s.size(); i++) {
- count1[s[i]-'a']++;
- count2[t[i]-'a']++;
- }
- for(int i=0; i<26; i++) {
- if (count1[i] != count2[i])
- return false;
- }
- return true;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement