String Rotation Check
Medium
string
rotation
substring
Problem Description
Check if one string is a rotation of another string using only one substring operation. A rotation means you can move characters from the beginning to the end or vice versa.
Input Format
Two strings on separate lines.
Output Format
Return "true" if the second string is a rotation of the first, "false" otherwise.
Constraints
• 1 ≤ string length ≤ 1000
• Both strings have the same length
• Strings contain only lowercase letters
• Use only one substring check operation
• Case-sensitive comparison
Sample Input/Output
Input:
abcde deabc
Output:
true
Explanation
"deabc" is a rotation of "abcde". If we concatenate "abcde" with itself: "abcdeabcde", we can find "deabc" as a substring. This is the key insight for solving with one substring check.
Solution Hints
75
Points
Points
2000ms
Time Limit
Time Limit
128MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now