Given two strings(S1 and S2), write a program to determine if a string S2 is a rotation of another string S1.
string1 = "XXYZ"
string2 = "XYZX"
print("String-1: ",string1)
print("String-2: ",string1)
s1 = len(string1)
s2 = len(string2)
temp = ''
if(s1 != s2):
print ("\nStrings are NOT rotations of each other: Reason: String's sizes are different.")
tempString = string1 + string1
if(tempString.count(string2)> 0):
print ("\nStrings are rotations of each other")
else:
print ("\nStrings are not rotations of each other")
Comments
Leave a comment