#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param s string字符串
# @param c string字符串
# @return int整型
#
class Solution:
def isCongruent(self , s: str, c: str) -> int:
# write code here
dic={}
for char in s:
if char not in dic:
dic[char]=1
else:
dic[char]+=1
for char in c:
if char not in dic:
return -1
else:
dic[char]-=1
if dic[char]==0:
del dic[char]
if len(dic)==0:
return len(s)
else:
return -1


京公网安备 11010502036488号