Skip to content

Commit a636a67

Browse files
committed
Solved 218. Valid Anagram using Python code
1 parent 9a78a48 commit a636a67

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

valid-anagram/KwonNayeon.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1+
"""
2+
Constraints:
3+
- 1 <= len(s), len(t) <= 50_000
4+
- s and t consist of lowercase English letters (a-z) only
15
6+
Time Complexity:
7+
- O(n log n)
8+
Space Complexity:
9+
- O(n)
10+
"""
211

12+
class Solution:
13+
def isAnagram(self, s: str, t: str) -> bool:
14+
15+
s = s.replace(' ', '').lower()
16+
t = t.replace(' ', '').lower()
17+
18+
if sorted(s) == sorted(t):
19+
return True
20+
else:
21+
return False

0 commit comments

Comments
 (0)