Skip to content

Commit 271957c

Browse files
committed
Valid Anagram 😈
1 parent 83b7c4a commit 271957c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

β€Žvalid anagram.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+
if s==t: return True
4+
if len(s)!=len(t): return False
5+
v = [0]*26
6+
for i in range(len(s)):
7+
v[ord(s[i])-ord('a')] += 1
8+
v[ord(t[i])-ord('a')] -= 1
9+
for i in range(26):
10+
if v[i]: return False
11+
return True
12+
13+

0 commit comments

Comments
Β (0)