Android & iPhone apps are coming soon. Log in for a plan and reminders made for you →

Warm-ups Ā· 21 of 24

Check if two strings are rotations

Return true if goal can be made by moving some characters from the front of s to its end.

Jump to the editor ↓

Examples

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

Output true

Move "ab" to the end.

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

Output false

šŸ“˜ New to this? Building a new string or array as the answer explains the idea in a few minutes.

Solved it? The same idea on LeetCode: try it there ↗

Your code

Tab indents · ⌘/Ctrl+Enter runs · Esc leaves the editor

Stuck?