@kartik:
i thnk u r searching for string...that may have characters..in the 2d matrix
..NO MATTER WHERE THEY ARE..


On Wed, Sep 21, 2011 at 7:10 PM, kartik sachan <kartik.sac...@gmail.com>wrote:

> i think i can solve this in O(n^2)
> here is code http://ideone.com/Gk69A
>
> # include<stdio.h># include<string.h>char a[100][100];int findword(int *b,int 
> n,int m){
>         int i,j,flag=0;
>         char s[10000];
>
>         for(i=0;i<n;i++)
>
>                 for(j=0;j<m;j++)
>                         s[a[i][j]]++;
>         for(i=0;i<strlen(b);i++)
>                 if(s[b[i]]!=0)
>                         s[b[i]]--;
>                 else
>                         {flag=0; break;}
>         if(flag==0)
>         return 0;
>         else
>         return 1;}int main(){
>         int i,j,n,m;
>         char str[10000];
>         scanf("%d %d",&n,&m);
>
>         for(i=0;i<n;i++)
>
>                 for(j=0;j<m;j++)
>                         scanf("%c",&a[i][j]);
>                 scanf("%s",str);
>         if(findword(str,n,m))
>         printf 
> <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("word 
> is there in matrix");
>         else
>         printf 
> <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("word 
> is not there in matrix");return 0;}
>
> plzz correct me if i am worng................
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@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.
>



-- 
*Dheeraj Sharma*
Comp Engg.
NIT Kurukshetra

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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