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
The detailed answer for the above question is provided below importjava... View full answer
Get step-by-step solutions from verified subject matter experts
