- Valid Anagram
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
CODE:
`class Solution:
def isAnagram(self, s, t):
if len(s) != len(t):
return False
arr = [0] * 26
for i in range(len(s)):
arr[ord(s[i]) - ord('a')] += 1
arr[ord(t[i]) - ord('a')] -= 1
for check in arr:
if check != 0:
return False
return True`
Top comments (0)