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)

京公网安备 11010502036488号