Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- M-1
- class Solution:
- def isAnagram(self, s: str, t: str) -> bool:
- #sort the string and compare
- if sorted(s)==sorted(t):
- return True
- else:
- return False
- M-2:
- #use the map, count each character in both string and then compare character by character
- from collections import Counter
- class Solution:
- def isAnagram(self, s: str, t: str) -> bool:
- print(Counter(s))
- return Counter(s) == Counter(t)
Advertisement
Add Comment
Please, Sign In to add comment