[Python] 2 Oneliners, explained
This is very very classical problem and if for some reason interviewer decides to ask it, you response time should be very quick.\n\nFirst solution is to sort b
This is very very classical problem and if for some reason interviewer decides to ask it, you response time should be very quick.\n\nFirst solution is to sort both strings and check if we have the same result. In python it can be done just with one short line. Time complexity is `O(n log n)` to perform sort, space depends on which sorting technique we will use, for the following code it is `O(n)`.\n\n```\nclass Solution:\n    def isAnagram(self, s, t):\n        return sorted(s) == sorted(t)\n```\n\nActually, we do not really need to sort data, we just need to count how many times we have each symbol and there is very useful `Counter` function for this. Time complexity is `O(n)`, and space is `O(m)`, where `m` is size of alphabet we are using.\n\n```\nclass Solution:\n    def isAnagram(self, s, t):\n        return Counter(s) == Counter(t)\n```\n\nIf you have any questions, feel free to ask. If you like solution and explanations, please **Upvote!**\n
['Sorting']