Easy · Strings

Rotate string

Given two strings s and goal, return true if goal can be obtained from s by some number of rotations (each moves the first character of s to the end), otherwise false.

Examples

Example 1

{
  "s": "abcde",
  "goal": "cdeab"
}

Output: true

Example 2

{
  "s": "abcde",
  "goal": "abced"
}

Output: false

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Strings problems