Check Rotated String
Find if a string is a rotation of another by using only one substring call
def isRotation(s1: String, s2: String):Boolean = {
if (s1.length != s2.length) false
else s1.concat(s1) contains s2
}
isRotation("waterbottle", "erbottlewat")
Last updated