Update 0242.有效的字母异位词.md

添加新的python题解方法
This commit is contained in:
Zeeland
2022-11-05 18:22:51 +08:00
committed by GitHub
parent fe16fac72f
commit 7f53e73e54

View File

@ -154,6 +154,16 @@ class Solution:
return s_dict == t_dict
```
Python写法三(没有使用数组作为哈希表只是介绍Counter这种更方便的解题思路)
```python
class Solution(object):
def isAnagram(self, s: str, t: str) -> bool:
from collections import Counter
a_count = Counter(s)
b_count = Counter(t)
return a_count == b_count
```
Go