File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ '''
2+ νμ΄ :
3+ λ¬Έμμ΄ sμμ λ¬Έμκ° λμ¬ λλ§λ€ λμ
λ리μ μ μ₯νκ³ μ«μ μ¦κ°
4+ λ¬Έμμ΄ tμμ λμΌν λ¬Έμκ° λμ¬ λλ§λ€ μ«μ κ°μμν€κ³ 0λλ©΄ λμ
λ리μμ μ κ±°
5+ λμ
λ리μ μλ λ¬Έμκ° λμ€κ±°λ μμ
μ΄ λλ ν λμ
λλ¦¬κ° λΉμ΄μμ§ μλ€λ©΄ False
6+
7+ TC :
8+ forλ¬Έ λλ² λκΈ° λλ¬Έμ O(N)
9+
10+ SC :
11+ λμ
λ리 ν λΉνλ λ©λͺ¨λ¦¬λ₯Ό κ³ λ €νλ©΄ O(N)
12+ '''
13+
14+ class Solution :
15+ def isAnagram (self , s : str , t : str ) -> bool :
16+ if len (s ) != len (t ) :
17+ return (False )
18+ dic = {}
19+ for char in s :
20+ if char in dic :
21+ dic [char ] += 1
22+ else :
23+ dic [char ] = 1
24+ for char in t :
25+ if char in dic :
26+ dic [char ] -= 1
27+ if dic [char ] == 0 :
28+ dic .pop (char )
29+ else :
30+ return (False )
31+ if dic :
32+ return (False )
33+ else :
34+ return (True )
You canβt perform that action at this time.
0 commit comments