Check if strings are rotations of each other or not - Java
public class RotatedOrNot { public boolean isRotated(String realString, String stringToTest){ String helpingString = realString+realString; if(helpingString.contains(stringToTest)) return true; else return false; } }
public class RotatedOrNotTest { @Test public void testNormalCase() { RotatedOrNot rotatedOrNot = new RotatedOrNot(); assertEquals(true,rotatedOrNot.isRotated("abcde","cdeab")); } }
Comments
Post a Comment