LeetCode 242 Valid Anagram (Python)

Posted by 小明MaxMing on February 11, 2021

题目

Given two strings s and t , write a function to determine if t is an anagram of s.

解题思路

使用Counter统计两个字符串,判断是否相同

代码

class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        return Counter(s) == Counter(t)

视频讲解 YouTube<--欢迎点击订阅

视频讲解 bilibili<--欢迎点击订阅