Rotate String
EasyStringssimulation
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A *shift* on a string moves its first character to the end, so "abcde" becomes "bcdea".
Given strings s and goal, return true if s can turn into goal after zero or more shifts, and false otherwise.
Examples
Input: s = "abcde", goal = "cdeab"
Output: true
Two shifts: "abcde" -> "bcdea" -> "cdeab".
Input: s = "abcde", goal = "abced"
Output: false
No rotation of "abcde" ends in "ced".
Constraints
- 1 <= s.length, goal.length <= 100
- `s` and `goal` consist of lowercase English letters
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.