fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main ( String[] args ) {
  8. Scanner in = new Scanner( System.in );
  9. String word1, word2;
  10. word1 = in.nextLine();
  11. word2 = in.nextLine();
  12. if ( sort ( word1 ).equals( sort ( word2 ) ) ) {
  13. System.out.print( "YES" );
  14. } else System.out.print( "NO" );
  15. }
  16. static String sort( String word1 ) {
  17. char[] content = word1.toCharArray();
  18. Arrays.sort( content );
  19. return new String( content );
  20. }
  21. }
Success #stdin #stdout 0.06s 711680KB
stdin
ananas

nnaass
stdout
NO