Skip to content

Commit 20d4573

Browse files
committed
#218 valid-anagram solution
1 parent c2652f9 commit 20d4573

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
ํ’€์ด :
3+
ํ•ด์‹œํ…Œ์ด๋ธ”์— string์„ ์ˆœํšŒํ•˜๋ฉฐ ๋ฌธ์ž : ๋นˆ๋„๋กœ ๊ฐ’ ์ €์žฅ ํ›„ ๋‘ ๋ฐ์ดํ„ฐ๊ฐ€ ๊ฐ™์€ ์ง€ ๋น„๊ต
4+
5+
TC : O(S + T)
6+
SC : O(S + T)
7+
*/
8+
9+
#include <unordered_map>
10+
#include <string>
11+
using namespace std;
12+
13+
class Solution {
14+
public:
15+
bool isAnagram(string s, string t) {
16+
unordered_map<char, int> s_map;
17+
unordered_map<char, int> t_map;
18+
19+
for (char c : s)
20+
s_map[c]++;
21+
for (char c : t)
22+
t_map[c]++;
23+
24+
return (s_map == t_map);
25+
}
26+
};

0 commit comments

Comments
ย (0)