LCR 032. 有效的字母异位词
为保证权益,题目请参考 LCR 032. 有效的字母异位词(From LeetCode).
解决方案1
Python
python
from collections import Counter
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(s) != len(t):
return False
if s == t:
return False
sc = Counter(s)
tc = Counter(t)
if len(sc) != len(tc):
return False
for k in sc.keys():
if sc[k] != tc[k]:
return False
return True
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22