#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param s string字符串
# @param c string字符串
# @return int整型
#
class Solution:
def isCongruent(self , s: str, c: str) -> int:
# write code here
arr1=[0]*26
arr2=[0]*26
for ch in s:
arr1[ord(ch)-ord('a')]+=1
for ch in c:
arr2[ord(ch)-ord('a')]+=1
count=0
for i in range(len(arr1)):
if arr1[i]!=arr2[i]:
return -1
else:
count+=arr1[i] # 统计次数
return count

京公网安备 11010502036488号