Skip to content

Commit 2ed6480

Browse files
committed
valid-anagram solution
1 parent cbe4aeb commit 2ed6480

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from collections import Counter
2+
3+
class Solution:
4+
def isAnagram(self, s: str, t: str) -> bool:
5+
"""
6+
๋‘ ๋ฌธ์ž์—ด์ด anagram์ธ์ง€ ํ™•์ธํ•œ๋‹ค.
7+
Counter๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž ๋นˆ๋„์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๊ณ  ๋น„๊ตํ•œ๋‹ค.
8+
์‹œ๊ฐ„๋ณต์žก๋„ O(n), ๋ฌธ์ž์—ด์„ ํ•œ ๋ฒˆ ์ˆœํšŒํ•˜์—ฌ ๋นˆ๋„์ˆ˜๋ฅผ ๊ณ„์‚ฐ
9+
"""
10+
return True if Counter(s) == Counter(t) else False

0 commit comments

Comments
ย (0)