All problems
Rotate String Check
Problem
Return True if goal can be obtained by rotating s some number of positions to the left.
A rotation of s is always a substring of s concatenated with itself, so check membership of goal in s + s after confirming equal lengths. Empty strings rotate to each other.
Hint
s + s contains every rotation of s as a contiguous block.
Test cases
case 1
in: ["abcde","cdeab"]
expected: true
case 2
in: ["abcde","abced"]
expected: false
case 3
in: ["",""]
expected: true
case 4
in: ["a","a"]
expected: true
case 5
in: ["abc","cab"]
expected: true
Starter codePython
def rotate_string(s, goal):
# Your code here
pass5 test cases · run your code against them in the editor