Concatenate the string to itself and if the given string is a substring of
the new concatenated string then it is a cyclic string
On Sat, Sep 11, 2010 at 3:38 PM, Ashim Kapoor wrote:
> I can do it in 2 O(n)sweeps if all elements are distinct.
> 12345
> 23451
>
> Sweep one to find the 1st element
I can do it in 2 O(n)sweeps if all elements are distinct.
12345
23451
Sweep one to find the 1st element of string 1 in string 2.
Sweep 2 to compare each element of the 2 strings from the position mod n
found in the 1st sweep.
I dont know how to do it if elements are repeated.
but the way Praveen
str="hello";
str1="lloeh";
if (str+str).subString(str1) is true then the string is cyclic string of
another
On Sat, Sep 11, 2010 at 1:52 PM, bittu wrote:
> How will you check if a string is cyclic string of another
>
> solution O(n)..???/?? or even less compraiosn..
>
> --
> You received thi
How will you check if a string is cyclic string of another
solution O(n)..???/?? or even less compraiosn..
--
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 fr