当前位置:网站首页>String-4-242. Valid Letter ectopic words

String-4-242. Valid Letter ectopic words

2022-06-09 23:16:00 Artificial intelligence Zeng Xiaojian

Given two strings s and t , Write a function to determine t Whether it is s Letter heteronym of .

Be careful : if s and t Each character in the has the same number of occurrences , said s and t They are mutually alphabetic words .

#  Method 3- Direct initialization counter 

class Solution:

    def isAnagram(self, s: str, t: str) -> bool:

        if len(s) != len(t):

            return False

        return Counter(s) == Counter(t)


# Initialize counter 
class Solution:
    def isAnagram(self,s:str,t:str) -> bool:
        if len(s) != len(t):
            return False
        return Counter(s) == Counter(t)

原网站

版权声明
本文为[Artificial intelligence Zeng Xiaojian]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206092231353497.html