Lintcode 158. Valid Anagram (Easy) (Python)

158. Valid Anagram

Description:

Write a method anagram(s,t) to decide if two strings are anagrams or not.

Example
Given s = “abcd”, t = “dcab”, return true.
Given s = “ab”, t = “ab”, return true.
Given s = “ab”, t = “ac”, return false.

Code:

class Solution:
    """
    @param s: The first string
    @param t: The second string
    @return: true or false
    """
    def anagram(self, s, t):
        # write your code here
        return sorted(s) == sorted(t)

猜你喜欢

转载自blog.csdn.net/weixin_41677877/article/details/80968861