Home > Algorithms > Given 2 strings, find weather second string is a rotation of first or not

Given 2 strings, find weather second string is a rotation of first or not

July 7, 2012

String s1 = "MISYS";
String s2 = "YSMIS";
String s1 = s1 + s1;
If(s1.contains(s2))
Print “Rotated String”
Else
Print “Not Rotated”

Advertisements
Categories: Algorithms
%d bloggers like this: