MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / anagramSeach

Function anagramSeach

CPP/String/angramSearch.cpp:16–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16bool anagramSeach(string txt, string pat)
17{
18 int n = txt.length();
19 int m = pat.length();
20 int ct[CHAR] = {0};
21 int cp[CHAR] = {0};
22 for (int i = 0; i < m; i++)
23 {
24 ct[txt[i]]++;
25 cp[pat[i]]++;
26 }
27 if (m == n)
28 return isSame(ct, cp);
29 for (int i = m; i < n; i++)
30 {
31 if (isSame(ct, cp))
32 return true;
33 ct[txt[i]]++;
34 ct[txt[i - m]]--;
35 }
36 return false;
37}
38
39int main()
40{

Callers 1

mainFunction · 0.85

Calls 2

isSameFunction · 0.85
lengthMethod · 0.80

Tested by

no test coverage detected