Using XOR operator for finding duplicate elements in a array fails in many cases
I came across a post How to find a duplicate element in an array of shuffled consecutive integers? but later realized that this fails for many input.
For ex:
arr[] = {601,602,603,604,605,605,606,607}
#include <stdio.h>
int main()
{
int arr[] = {2,3,4,5,5,7};
int …
XOR two Binary Strings c++
I have two strings as follows :
STRING1 : 011011110011000
STRING2 : 011001000001000
EXPECTED OUTPUT : 000010110010000
However, when i try to XOR them(bit-wise) using the following code, the output is blank.
Code:
for(int i = 0; i<15; i++)
{
final_key[i] = STRING1[i] ^ STRING2[i];
…