#=================================== # Tanzila Islam # Email: tanzilamohita@gmail.com # Language: Python 3 #=================================== class Solution: def isAnagram(self, s: str, t: str) -> bool: if len(s) != len(t): return 0 else: dict_ana = {} for val in s: if val in dict_ana: dict_ana[val] += 1 else: dict_ana[val] = 1 for val in t: if val in dict_ana: dict_ana[val] -= 1 if not any(dict_ana.values()): return 1 else: return 0
No comments:
Post a Comment