796. Rotate String
Example 1:
Input: A = 'abcde', B = 'cdeab'
Output: true
Example 2:
Input: A = 'abcde', B = 'abced'
Output: falsebool rotateString(string A, string B) { // time: O(n + m); space: O(n)
string tmp = A + A;
return A.length() == B.length() && tmp.find(B) != string::npos;
}Last updated