Skip to content

Commit 8ce8f25

Browse files
committed
Anagram
1 parent f445f71 commit 8ce8f25

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

valid-anagram/EstherKim97.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution(object):
2+
def isAnagram(self, s, t):
3+
character1 = []
4+
character2 = []
5+
6+
# put characters in character1 and character2
7+
for i in s:
8+
character1.append(i)
9+
for i in t:
10+
character2.append(i)
11+
12+
# sort out the characters in alphabetical order
13+
character1.sort()
14+
character2.sort()
15+
16+
# compare each characters to see if they match (= anagram)
17+
if character1 == character2:
18+
return True
19+
else:
20+
return False

0 commit comments

Comments
 (0)