Spoj FINDSR - Find String Roots Solution
#include<bits/stdc++.h> using namespace std; void arraycal(string pat, int M, int lps[]) { int len = 0; lps[0] = 0; int i = 1; while (i < M) { if (pat[i] == pat[len]) { len++; lps[i] = len; i++; } else { if (len != 0) { len = lps[len-1]; } else { ...