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.
Here is the solution for XOR Strings 2 in Java7 because for Java 8 they did not give any code to modify but we have to modiy only 3 lines according to question.
public static String stringsXOR(String s, String t) {
String res = new String("");
for(int i = 0; i < s.length(); i++) {
if(s.charAt(i) != t.charAt(i))
res += "1";
else
res += "0";
}
return res;
}
public static void main(String[] args) {
String s, t;
Scanner in = new Scanner(System.in);
s = in.nextLine();
t = in.nextLine();
System.out.println(stringsXOR(s, t));
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
XOR Strings 2
You are viewing a single comment's thread. Return to all comments →
Here is the solution for XOR Strings 2 in Java7 because for Java 8 they did not give any code to modify but we have to modiy only 3 lines according to question.
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}