I have two strings a and b. I want to know if a is rotation of b or vice versa without creating a third string.
I have two strings a and b . I want to know if a
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A string a is a rotation of b if and only if there is an L such that L == len(a) == len(b), and there is an offset 0 <= j < len(a) such that a[ (i+j) % L] == b[i] for all 0 <= i < L.
In c code (assuming that L is the common length of the strings. Returns 1 if a is a rotation of b, 0 otherwise):