I found one interesting question
Given a string s , return the shortest substring that is
only occurring once.
Examples:
s=aabbabbaab gives either bab or baa
s= gives
My Approaches
Generate All Possible SubStrings O(N^2)
puts all substrings into hashtable keep incrementing counter for
This looks like a good problem. Could you confirm if string contains only
two characters as you mentioned in both examples or it is a general string
with any characters.
On Tue, Jun 14, 2011 at 6:33 PM, bittu shashank7andr...@gmail.com wrote:
I found one interesting question
Given a string s
it must be any general string
Suffix tree approach seems best both in time and space complexity
On Tue, Jun 14, 2011 at 7:36 PM, Navneet Gupta navneetn...@gmail.comwrote:
This looks like a good problem. Could you confirm if string contains only
two characters as you mentioned in both
But generating a suffix tree itself is O(n2) .
On Tue, Jun 14, 2011 at 7:54 PM, sunny agrawal sunny816.i...@gmail.comwrote:
it must be any general string
Suffix tree approach seems best both in time and space complexity
On Tue, Jun 14, 2011 at 7:36 PM, Navneet Gupta