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 d7db655 commit 3f656beCopy full SHA for 3f656be
โvalid-anagram/socow.pyโ
@@ -0,0 +1,15 @@
1
+# ๋ฌธ์ ๋ด์ฉ
2
+# ๋ ๋ฌธ์์ด s์ t๊ฐ ์ฃผ์ด์ง ๋, t๊ฐ s์ ์ ๋๊ทธ๋จ(anagram)์ธ์ง ํ๋ณํ๋ผ.
3
+# ์ ๋๊ทธ๋จ์ด๋ ๊ฐ์ ๋ฌธ์๋ฅผ ๊ฐ์ ๊ฐ์๋งํผ ์ฌ์ฉํด ์์๋ง ๋ฐ๊พผ ๋ฌธ์์ด์ ๋งํด.
4
+# ๊ฒฐ๊ณผ: ์ ๋๊ทธ๋จ์ด๋ฉด True, ์๋๋ฉด False.
5
+
6
+# sorted(): ๋ฌธ์์ด์ ํ ๊ธ์์ฉ ์๋ผ ์ค๋ฆ์ฐจ์ ์ ๋ ฌํด์ ๋น๊ต (๊ฐ๋จ, ์ง๊ด)
7
+# 1. sorted()๋ก ๋ ๋ฌธ์์ด์ ์ ๋ ฌํด์ ๋น๊ต
8
+# 2. ์ ๋ ฌ๋ ๊ฒฝ๊ณผ๊ฐ ๊ฐ์ผ๋ฉด True ์๋๋ฉด False
9
+# ์๊ฐ๋ณต์ก๋: O(n log n)
10
+# ๊ณต๊ฐ๋ณต์ก๋: O(n)
11
+class Solution:
12
+ def isAnagram(self, s: str, t: str) -> bool:
13
+ if len(s) != len(t):
14
+ return False
15
+ return sorted(s) == sorted(t)
0 commit comments