Skip to content

Commit 261b33e

Browse files
authored
Create 242. Valid Anagram.py
1 parent 352700a commit 261b33e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def isAnagram(self, s: str, t: str) -> bool:
3+
if len(t) != len(s):
4+
return False
5+
6+
counter1 = Counter(s)
7+
counter2 = Counter(t)
8+
9+
for char1, freq in counter1.items():
10+
if counter2[char1] != freq:
11+
return False
12+
return True

0 commit comments

Comments
 (0)