fork download
  1. /**
  2.  * Check if Given strings are roated form of each other
  3.  * @author PRATEEK
  4.  */
  5. class RotatedStrings {
  6.  
  7. public static void main(String[] args) {
  8. System.out.println(isRotated("coding","dingco"));
  9. }
  10.  
  11. /**
  12. * @return: true if strings are rotated form of each other
  13. */
  14. public static boolean isRotated(String s1,String s2){
  15. return s1.length()==s2.length() && (s1+s1).indexOf(s2)!=-1 ;
  16. }
  17. }
  18.  
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
true