We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4757ac8 commit 9503fe0Copy full SHA for 9503fe0
1 file changed
src/hackerrank/XORStrings.java
@@ -0,0 +1,21 @@
1
+package hackerrank;
2
+
3
+public class XORStrings {
4
+ public static String stringsXOR(String s, String t) {
5
+ // 0과 1로된 두 개의 문자열에서 XOR값을 리턴하는 문제
6
+ // XOR란 같으면 0 다르면 1을 출력한다.
7
+ // 주어진 코드 중 3줄만 수정가능하고 새로운 코드를 추가하거나 기존 코드를 제거하면 안된다.
8
+ String res = new String("");
9
+ for(int i = 0; i < s.length(); i++) {
10
+ if(s.charAt(i) == t.charAt(i))
11
+ res += "0";
12
+ else
13
+ res += "1";
14
+ }
15
+ return res;
16
17
18
+ public static void main(String[] args) {
19
+ System.out.println(stringsXOR("10101", "00101")+", ans: 10000");
20
21
+}
0 commit comments