Re: [algogeeks] MS Question : find word in 2D array

2012-06-09 Thread Bhaskar Kushwaha
@utsav u haven't initialized match anywhere so ur algo fails On Thu, Jun 7, 2012 at 2:50 AM, utsav sharma utsav.sharm...@gmail.comwrote: i think it can be solved using DP word=bcdf take hash of word h[b]=1 h[c]=2 h[d]=3 h[f]=4 given 2d matrix m[][]= {b c b e f g h b c d f p o u d f d

[algogeeks] MS Question : find word in 2D array

2012-06-06 Thread Ashish Goel
WAP to find a word in a 2D array. The word can be formed on row/col/diagnal/reverse diagnal Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] MS Question : find word in 2D array

2012-06-06 Thread atul anand
i did this question long time back well simple brute force check can be doneyou can keep one flag matrix of same size to avoid necessary recursion. On 6/6/12, Ashish Goel ashg...@gmail.com wrote: WAP to find a word in a 2D array. The word can be formed on row/col/diagnal/reverse

Re: [algogeeks] MS Question : find word in 2D array

2012-06-06 Thread utsav sharma
i think it can be solved using DP word=bcdf take hash of word h[b]=1 h[c]=2 h[d]=3 h[f]=4 given 2d matrix m[][]= {b c b e f g h b c d f p o u d f d f g k p } take another matrix match[][] if( h[ m[i][j] ] 0 ) //if this char is in word then {a=h[ m[i][j] ]; if (match[i-1][j] ==a-1