Question
Write an efficient program to test if two given String is a rotation of each other or not, Ex: If the given String is XYZ
Write an efficient program to test if two given String is a rotation of each other or not, Ex:
If the given String is "XYZ" and "ZXY" then your function should return true. But if the input is "XYZ" and "YXZ" then return false.
Example:
Input:
Please enter original string: XYZ Please enter rotation string: ZXY
Output:
XYZ and ZXY are rotation to each other.
Example:
Input:
Please enter original string: XYZ Please enter rotation string: ABC
Output:
Sorry, they are not rotation of another.
Example: Input:
Please enter original string: XYZ Please enter rotation string: ZYX
Output:
Sorry, they are not rotation of another.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The detailed answer for the above question is provided below importjava...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started