- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestclass.cpp
More file actions
Latest commit
32 lines (26 loc) · 611 Bytes
/
Copy pathtestclass.cpp
File metadata and controls
32 lines (26 loc) · 611 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
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
usingnamespacestd;
classSolution {
public:
boolisAnagram(string s, string t) {
int arr[26] = {0,};
if (s.length() != t.length()) returnfalse;
for (auto a : s)
{
arr[a - 'a']++;
}
// 문자열 길이가 같으므로 다른게 하나라도 있으면 0보다 작은것도 존재
for (auto a : t)
{
if (--arr[a - 'a'] < 0) returnfalse;
}
returntrue;
}
};