Form String by Rotation
JAVA CODE:
import java.util.*;
public class Hello {
static boolean arerot(String a1,String a2)
{
return(a1.length()==a2.length())&&((a1+a1).indexOf(a2) != -1);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String a1=sc.next();
String a2=sc.next();
if(arerot(a1,a2))
System.out.println("Yes");
else
System.out.println("No");
}
}
Comments
Post a Comment