1. 程式人生 > >【leetcode 簡單】 第七十題 有效的字母異位詞

【leetcode 簡單】 第七十題 有效的字母異位詞

給定 etc turn dot 怎麽辦 sorted 說明 ott 編寫

給定兩個字符串 st ,編寫一個函數來判斷 t 是否是 s 的一個字母異位詞。

示例 1:

輸入: s = "anagram", t = "nagaram"
輸出: true

示例 2:

輸入: s = "rat", t = "car"
輸出: false

說明:
你可以假設字符串只包含小寫字母。

進階:
如果輸入字符串包含 unicode 字符怎麽辦?你能否調整你的解法來應對這種情況?

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


【leetcode 簡單】 第七十題 有效的字母異位詞