Valid Anagram ( LeetCode ) Problem Solution.
Given two strings s and t , write a function to see if t is an anagram of s.
Example 1:
Input: s = "anagram", t = "nagaram" Output: true
Example 2:
Input: s = "rat", t = "car" Output: false
Solution :-
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
counts=Counter(s)
print(counts)
countt=Counter(t)
if(counts==countt):
return True
else:
return False
Runtime: 28 ms, faster than 99.08% of Python3 online submissions for Valid Anagram.
Memory Usage: 14.3 MB, less than 6.25% of Python3 online submissions for Valid Anagram.
0 Comments