/* Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may assume that n > m. Input: txt[] = "AABAACAADAABAABA" pat[] = "AABA" Output: Pattern found at index 0 Pattern found at index 9 Pattern found at index 12 */ #include using namespace std; void computeLPS(string pat, int lps[]){ // length of the previous longest prefix suffix int len=0; int i=1; lps[0]=0; int m=pat.length(); while(i>t; while(t--){ string txt, pat; cin>>txt>>pat; kmp(txt, pat); } return 0; }