We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
//Java, the website has some complie problem, the answer is correct, but it says it's wrong.
public class Solution {
public static void main(String args[] ) throws Exception {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
Scanner sc = new Scanner(System.in);
String s1 = sc.next();
String s2 = sc.next();
String output = xor(s1,s2);
System.out.println(output);
}
public static String xor(String s1, String s2){
String res = "";
for(int i = 0; i < s1.length() ; i++){
if(s1.charAt(i) == s2.charAt(i)){
res += '0';
}else{
res += '1';
}
}
return res;
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
XOR Strings
You are viewing a single comment's thread. Return to all comments →
//Java, the website has some complie problem, the answer is correct, but it says it's wrong. public class Solution { public static void main(String args[] ) throws Exception { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ Scanner sc = new Scanner(System.in); String s1 = sc.next(); String s2 = sc.next(); String output = xor(s1,s2); System.out.println(output); }
}