Check if a string is rotation of another WITHOUT concatenating
algorithm, language-agnostic, string
Solution
One simple solution is by concatenating them and checking if the other one is a substring of the concatenated version.
I assume you mean concatenate the first string with itself, then check if the other one is a substring of that concatenation.
That will work, and in fact can be done without any concatenation at all. Just use any string searching algorithm to search for the second string in the first, and when you reach the end, loop back to the beginning.
For instance, using Boyer-Moore the overall algorithm would be O(n).
Problem
There are 2 strings , how can we check if one is a rotated version of another ? `For Example : hello --- lohel` One simple solution is by `concatenating` first string with itself and checking if the other one is a `substring` of the concatenated version. Is there any other solution to it ? I was wondering if we could use `circular linked list` maybe ? But I am not able to arrive at the solution.