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.
- XOR Strings 2
- Discussions
XOR Strings 2
XOR Strings 2
Sort by
recency
|
250 Discussions
|
Please Login in order to post a comment
I tried to submit the following method: public static void main(String args[] ) throws Exception { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); String s = bufferedReader.readLine(), t = bufferedReader.readLine(); System.out.println(IntStream.range(0, s.length()).mapToObj(i -> String.valueOf(s.charAt(i) ^ t.charAt(i))).collect(Collectors.joining()));
} although it visually presents the same result. It is difficult to understand what the real problem is.
I have checked multiple times, my logic is correct, the output I am printing is also correct but compiler says wrong answer. Any idea? Compiler Message: Wrong Answer Input (stdin) 10101 00101 Your Output (stdout) 10000 Expected Output 10000
C++ test:
do not refactor, just fix three errors. There is a bug somewhere on test backend, it fails tests if submitted under C++20/C++23. If submitted under C++14, it passes all tests. It is a bug on the HR backend, the same code compiled under gcc with C++20 compliance works just fine.
for java user 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 += "0"; else res += "1"; } use this code it will clear as the note in problem suggest to to not delete or add code annd only 3 changes so this will help as i cleared return res; }
"I've been working on the function and encountered an issue that I haven't been able to resolve. Here's the code I'm using:
Java 7
public class Solution {
It passes basic test cases manually, but when running in the environment, it fails with a 'Wrong Answer' message.
I can't figure out where the issue lies, as both the outputs seem the same. If anyone can provide insights or point out anything I might have missed, I'd really appreciate the help. Thanks in advance!"
}