This post is completed by 1 user
|
Add to List |
Check if one string is Rotation of another string
Objective: Write an algorithm to check if one string is Rotation of another string. This question has been asked in the Amazon interview.
Example:
Input Strings : 'sumitjain' and 'tjainsumi' Output : true Input String : 'Jaain' and 'ainJ' Output: false
Input: Two Strings
Output: True or false based on whether strings are rotation of each other.
Approach:
- Make a new String by appending the appending the first string with itself
- Check if second string is sub string of new String
Code:
Is 'sumitjain' and 'tjainsumi' are rotated?? : true
Also Read: