Using a trie data structure this can be solved in O(n). read each character of the input string and build a trie. Maintain the counts of all words.
Now traverse the trie again with the input string and making decisions whether to print a string depending on the word count that you get from the trie. On Aug 5, 1:21 pm, vaibhav shukla <[email protected]> wrote: > Given a string,remove all duplicates words: > > input: where there is a will there is a way > > o/p : where will way. > > -- > best wishes!! > Vaibhav > MCA -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
