题解 | 字母异位词的长度
字母异位词的长度
https://www.nowcoder.com/practice/59426f49136349b0901cc1b70447bf4b
from collections import Counter
class Solution:
def isCongruent(self, s: str, c: str) -> int:
if len(s) != len(c):
return -1
count = [0] * 26
for i in s:
count[ord(i) - ord("a")] += 1
for i in c:
count[ord(i) - ord("a")] -= 1
for i in range(26):
if count[i] != 0:
return -1
return len(s)


