> For the complete documentation index, see [llms.txt](https://maksimdan.gitbook.io/interview-practice-problems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maksimdan.gitbook.io/interview-practice-problems/coding_practice_questions/interview_questions1/string-rotation.md).

# String Rotation

**1.9 String Rotation:** Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, 51 and 52, write code to check if 52 is a rotation of 51 using only one call to isSubstring (e.g., "waterbottle" is a rotation of"erbottlewat").

* Brainstorm:
  * if we preform s1+s1 then the result is guaranteed to have the full word within it.

```cpp
bool isRotation(string s1, string s2) {
  if (s1.length() > 0 && s2.length() > 0 && s1.length() == s2.length())  {
    return isSubstring(s2, s1+s1);
  }
  return false;

}
```
