-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path242.cpp
More file actions
33 lines (24 loc) · 667 Bytes
/
242.cpp
File metadata and controls
33 lines (24 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Written by Nitin Kumar Maharana
* nitin.maharana@gmail.com
*/
class Solution {
public:
bool isAnagram(string s, string t) {
int memory[26];
int slen, tlen;
slen = s.length();
tlen = t.length();
if(slen != tlen)
return false;
memset(memory, 0, sizeof(memory));
for(int i = 0; i < slen; i++)
memory[s[i]-'a']++;
for(int i = 0; i < tlen; i++)
memory[t[i]-'a']--;
for(int i = 0; i < 26; i++)
if(memory[i])
return false;
return true;
}
};