Created
October 19, 2015 10:07
-
-
Save vdonchev/a20f40f3d991b7f53050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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