diff --git a/python/0242-valid-anagram.py b/python/0242-valid-anagram.py index ad374a605..688d67f1e 100644 --- a/python/0242-valid-anagram.py +++ b/python/0242-valid-anagram.py @@ -9,3 +9,10 @@ def isAnagram(self, s: str, t: str) -> bool: countS[s[i]] = 1 + countS.get(s[i], 0) countT[t[i]] = 1 + countT.get(t[i], 0) return countS == countT + + +# Time Complexity = O(nlogn) +# Space Complexity = O(n) +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + return sorted(s) == sorted(t)