My one line solution in Python

  • 0
    class Solution:
        def isAnagram(self, s, t):
            return ''.join(sorted(s)) == ''.join(sorted(t))

  • 0

    I think sorted function in python return a list. so you don't need to use join method and just compare the two list
    return sorted(s)==sorted(t)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.