We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
bool CheckAna(string & s, int start1, int start2, int len)
{
int let[26] = {0};
bool result = true;
for (int n = 0; n < len; n++)
{
let[s[start1+n]-'a']++;
let[s[start2+n]-'a']--;
}
for (int n= 0; n <26; n++)
{
if (let[n] != 0)
{
result = false;
break;
}
}
return result;
}
P.D. haven't yet looked for a way to properly format the code in the posting
P.D. 2. Appears that code must start with a tab before each line (?)
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
Shorter in c++, saves one loop):
P.D. haven't yet looked for a way to properly format the code in the posting
P.D. 2. Appears that code must start with a tab before each line (?)