Check if a string is rotation of another WITHOUT concatenating

后端 未结 11 1418
死守一世寂寞
死守一世寂寞 2020-12-25 08:11

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 co

11条回答
  •  鱼传尺愫
    2020-12-25 08:56

    A very straightforward solution is to rotate one of the words n times, where n is the length of the word. For each of those rotations, check to see if the result is the same as the other word.

提交回复
热议问题