it can be solved in O(n). let query array be b[k] and array of int is a[n],
int j=i=0, s=-1; for(i=0;i<n;i++) { if(a[i]==b[j]) { j++; if(j==1) s=i; } else { j=0; s=-1; } if(j==k) break; } if( i<=n && j==k) printf("Found starting index=%d",s); else printf("NOt found"); return 0; } On Oct 7, 1:20 pm, RAHUL KUJUR <kujurismonu2...@gmail.com> wrote: > @prodigy: how is it coming O(nlogk) can u explain??? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.