Check whether one string is a rotation of another

1 min read

https://www.geeksforgeeks.org/a-program-to-check-if-strings-are-rotations-of-each-other/

bool areRotations(string str1, string str2) {
  if (str1.length() != str2.length())
    return false;

  string temp = str1 + str1;
  return (temp.find(str2) != string::npos);
}
Why are strings immutable in Java?
Check whether a string is a valid shuffle of two strings