Your Solution considers only those windows which contain continuous
elements of query array in input array.
It won't work for:
i/p array : 12345
query array: 1235

also it won't work for:
i/p array: 11112
query array: 1112

Ankit Agarwal





On Oct 10, 9:04 pm, Mridul Malpani <malpanimri...@gmail.com> wrote:
> 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.

Reply via email to