fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. int i,j;
  14. String S,T;
  15. Scanner sc = new Scanner(System.in);
  16. S=sc.nextLine();
  17. T=sc.nextLine();
  18. i=0;
  19. j=T.length()-1;
  20. if(S.length()==T.length())
  21. {
  22. while(S.charAt(i)==T.charAt(j))
  23. {
  24. if((i<S.length()-1)&&(j>0))
  25. {
  26. i++;
  27. j--;
  28. }
  29. else
  30. break;
  31. }
  32. if(j==0&&(i==S.length()-1))
  33. System.out.println("YES");
  34. else
  35. System.out.println("NO");
  36. }
  37. else
  38. System.out.println("NO");
  39. }
  40. }
Success #stdin #stdout 0.09s 380672KB
stdin
code
edoc
stdout
YES