But generating a suffix tree itself is O(n2) .

On Tue, Jun 14, 2011 at 7:54 PM, sunny agrawal <sunny816.i...@gmail.com>wrote:

> 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.com>wrote:
>
>> 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 , return the shortest substring that is
>>> only occurring once.
>>> Examples:
>>> s="aabbabbaab" gives either "bab" or "baa"
>>> s="aaaa" gives "aaaa"
>>>
>>> My Approaches
>>>
>>> Generate All Possible SubStrings O(N^2)
>>> puts all substrings into hashtable & keep incrementing counter for
>>> each substring , return substring with counter 1 memory O(N)
>>> Not efficient
>>>
>>> Create Suffix Tree Seems to be Efficient Solution Only You Need to do
>>> Create Tree & then we can find the
>>> shortest substring that is only occurring once. in O(n) time
>>>
>>> PS: let me other approaches,suggestion
>>>
>>> Thanks
>>> Shashank
>>> CSE,BIT Mesra
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> --Navneet
>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> 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.
>



-- 
AKSHAY RASTOGI
BE(Hons) CS
BITS PILANI , Pilani

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