Rotate String Problem

Rotate String Problem — ExecCode Easy DSA Practice

Solve the Rotate String problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. Your task is to a shift on s consists of moving the leftmost character of s to the rightmost position. For example, if s = "abcde", then it will be "bcdea" after one shift. Return the required answer exactly as shown in the examples.

Examples

Input {"s": "aaa", "goal": "aaa"}; Output True. Input {"s": "abcdefg", "goal": "efgabcd"}; Output True. Input {"s": "abab", "goal": "abba"}; Output False

Constraints

1 <= s.length, goal.length <= 100 s and goal consist of lowercase English letters.

Practice Rotate String free on ExecCode. Browse DSA problems, topic map, and placement guides.