Skip to content

Commit 843df19

Browse files
有效的字母异位词
collections.Counter
1 parent 9ccc261 commit 843df19

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

每日一题/242.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'''
2+
Descripttion: 有效的字母异位词
3+
version: 1
4+
Author: Jason
5+
Date: 2020-11-22 11:00:30
6+
LastEditors: Jason
7+
LastEditTime: 2020-11-22 11:09:50
8+
'''
9+
10+
11+
class Solution:
12+
def isAnagram(self, s: str, t: str) -> bool:
13+
from collections import Counter
14+
return Counter(s) == Counter(t)
15+
pass
16+
17+
18+
s = "rat"
19+
t = "car"
20+
print(sorted(s) == sorted(t))

0 commit comments

Comments
 (0)