| 14 | } |
| 15 | |
| 16 | bool 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 | |
| 39 | int main() |
| 40 | { |