int isCongruent(char* s, char* c ) {
// write code here
int hash[26] = {0};
int len_s = strlen(s);
int len_c = strlen(c);
if (len_s != len_c)
return -1;
for(int i = 0; i < len_c; i++)
{
hash[s[i] - 'a']++;
}
for(int i = 0; i < len_c; i++)
{
hash[c[i] - 'a']--;
}
for(int i = 0; i < 26; i++)
{
if(hash[i] != 0)
return -1;
}
return len_c;
}

京公网安备 11010502036488号