Merge pull request #1737 from Undertone0809/patch-1

Update 0242.有效的字母异位词.md
This commit is contained in:
程序员Carl 2022-11-21 11:54:42 +08:00 committed by GitHub
commit b7d29cbe04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -153,6 +153,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