how abt this..

Pass1 = look whether words like n,ne,new,news.....exist or not...store
information in some array like n is not found so is ne but new is found and
news is found so array will be like

0,0,1,1.....

Pass2 = do d same from from the end...

r,er,per,aper,paper....

0,0,1,0,1........

Pass3 on first array....

whenever you find 1....see index [len(newspaper) - (index of one in first
array)] in second array...if its one we have words n so on....



On Tue, Jan 11, 2011 at 6:58 PM, Vikas Singh <vikas.sing...@gmail.com>wrote:

> Wouldn't that be O(n2) . what if n, ne, new, news, newsp etc all are valid
> words ? Cant it be optimized?
>
> On Tue, Jan 11, 2011 at 6:27 PM, juver++ <avpostni...@gmail.com> wrote:
>
>> Use trie (or similar DS).
>> For each word, try to find second part of the target in a linear time
>> O(length).
>>
>> --
>> 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<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
--
Manoj Lalavat

-- 
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