Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Rotate String

XPChallenge Points: 10
levelLevel: Easy

You are given two strings s and goal.
Return true if and only if s can become goal after performing some number of left rotations.

A left rotation (shift) means removing the first character of s and appending it to the end.

Example:
"abcde""bcdea""cdeab" → …

To determine if goal is a rotation of s, notice that any rotation of s will always appear as a substring of s + s.

Example 1:

Input: s = "abcde", goal = "cdeab"

Output: true

Example 2:

Input: s = "abcde", goal = "abced"

Output: false

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result