We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6bdb8a9 commit 932b4f5Copy full SHA for 932b4f5
valid-anagram/Hong-Study.cpp
@@ -0,0 +1,34 @@
1
+'''
2
+Time Complexity: O(n log n)
3
+- 분류 정렬에서 O(n log n) 발생
4
+
5
+Run time
6
+- 7ms
7
8
+Memory
9
+- 9.56 MB
10
11
+최적화쪽으로 수정 추가 필요
12
13
+class Solution {
14
+public:
15
+ bool isAnagram(string s, string t) {
16
+ // 선 길이 체크
17
+ if (s.length() != t.length()) {
18
+ return false;
19
+ }
20
21
+ // 두 배열 정렬(n log n)
22
+ std::sort(s.begin(), s.end());
23
+ std::sort(t.begin(), t.end());
24
25
+ // 비교하여 다르면 false
26
+ for (int i = 0; i < s.length(); i++) {
27
+ if (s[i] != t[i]) {
28
29
30
31
32
+ return true;
33
34
+};
0 commit comments