Problem statement

https://leetcode.com/problems/rotate-string/

Solution

We just need to check that lengths of both strings are the same and B in A+A.

Complexity

Time complexity in python will be in average O(n), space is also O(n).

Code

class Solution:
    def rotateString(self, A, B):
        return len(A) == len(B) and B in A+A

Remark

Other algorithms are bruteforce with O(n^2)/O(1) time/space, KMP and Rolling hash with O(n)/O(n) time/space