Skip to content

Commit 35df9c2

Browse files
committed
valid-anagram solution
1 parent 620b3dd commit 35df9c2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

valid-anagram/Donghae0230.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def isAnagram(self, s: str, t: str) -> bool:
3+
s_list = sorted(list(s))
4+
t_list = sorted(list(t))
5+
# 1. 두 단어의 길이가 다른 경우 false 반환
6+
if len(s_list) != len(t_list):
7+
return False
8+
else:
9+
# 2. 각 알파벳의 순서가 일치하지 않는 경우 false 반환
10+
for i in range(0, len(s_list)):
11+
if s_list[i] != t_list[i]:
12+
return False
13+
return True

0 commit comments

Comments
 (0)