Skip to content

Instantly share code, notes, and snippets.

@vdonchev
Created October 19, 2015 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdonchev/a20f40f3d991b7f53050 to your computer and use it in GitHub Desktop.
Save vdonchev/a20f40f3d991b7f53050 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String word1 = input.next();
String word2 = input.next();
try {
for (int i = 0; i < word1.length(); i++) {
for (int j = i; j < word2.length(); j++) {
if((word1.charAt(i) == word1.charAt(j) && word2.charAt(i) != word2.charAt(j)) ||
(word1.charAt(i) != word1.charAt(j) && word2.charAt(i) == word2.charAt(j))
) {
System.out.println(false);
return;
}
}
}
} catch (Exception ex) {
System.out.println("Incorrect length");
}
System.out.printf("true");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment