[
string
kmp
]
BinarySearch 0030 Rotation of Another String
Problem statement
https://binarysearch.com/problems/Rotation-of-Another-String/
Solution
We can check if length of strings are equal and s1
in s0 + s0
.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, s0, s1):
return len(s0) == len(s1) and s1 in s0 + s0