String Rotation Checker - aloalgo

String Rotation Checker

Medium

You are given two strings, s1 and s2, determine if s2 is a rotation of s1. You can assume that the rotation operation can be performed on s1 to get s2 if they are rotations of each other. The strings will only contain lowercase English letters.

Example 1

Inputs
s1 = "waterbottle"
s2 = "erbottlewat"
Output
True
Explanation:

If 'waterbottle' is rotated, 'erbottlewat' can be formed. ('erbottlewat' is a substring of 'waterbottlewaterbottle')

Example 2

Inputs
s1 = "apple"
s2 = "pleap"
Output
True
Explanation:

If 'apple' is rotated, 'pleap' can be formed. ('pleap' is a substring of 'appleapple')

Example 3

Inputs
s1 = "apple"
s2 = "ppale"
Output
False
Explanation:

'ppale' cannot be formed by rotating 'apple'.

Loading...
Inputs
s1 = "waterbottle"
s2 = "erbottlewat"
Output
True

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!