Valid Anagram

Problem: Valid Anagram

What we need to do is judge whether the word-frequency dictionaries of two words are the same. A simple solution is to sort both words.

Code in Python:

class Solution(object):
    def isAnagram(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        return sorted(list(s)) == sorted(list(t))

results matching ""

    No results matching ""