This post is completed by 2 users

  • 1
Add to List
Beginner

26. Check if one string is Rotation of another string

Objective: Write an algorithm to check if one string is Rotation of another string. 

Example:

Input Strings : 'tutorialhorizon' and 'horizontutorial'
Output : true
Input String : 'horizontutorial' and 'horizonrial'
Output: false

Approach:

  • Make a new String by appending the appending the first string with itself
  • Check if second string is sub string of the first string
Check if one string is Rotation of another string

Output:

Is 'tutorialhorizon' and 'horizontutorial' are rotated?? : true