- #include
#include
using namespace std;
bool IsomorphicStrings(string s, string p)
{
if (s.size() != p.size())
{
return false;
}
int aclls[256] = { 0 };
int acllp[256] = { 0 };
int i = 0;
int j = 0;
while (i < s.size() && j < p.size())
{
aclls[s[i]]++;
acllp[p[j]]++;
if (aclls[s[i]] != acllp[p[j]])
{
return false;
}
i++;
j++;
}
return true;
}
int main()
{
string s = “paper”;
string t = “titly”;
cout << IsomorphicStrings(s, t) << endl;
system(“pause”);
return 0;
}
Isomorphic Strings 同构字符串
最新推荐文章于 2020-06-07 10:18:25 发布
