Complete the code to initialize the XOR result variable.
int xor_result = [1];We start XOR with 0 because XOR with 0 leaves the number unchanged.
Complete the code to XOR all elements in the array.
for (int i = 0; i < n; i++) { xor_result = xor_result [1] arr[i]; }
The XOR operator in C is '^'. It combines bits where only one bit is set.
Fix the error in finding the rightmost set bit mask.
int set_bit_mask = xor_result & [1] xor_result);To find the rightmost set bit, we AND xor_result with its two's complement (-xor_result).
Fill both blanks to separate the two unique numbers using the set bit mask.
int num1 = 0, num2 = 0; for (int i = 0; i < n; i++) { if (arr[i] & [1]) { num1 = num1 [2] arr[i]; } else { num2 = num2 ^ arr[i]; } }
We check if the element has the set bit using 'set_bit_mask'. Then XOR elements in each group separately.
Fill in the blank to print the two unique numbers in ascending order.
if (num1 [1] num2) { printf("%d %d\n", num1, num2); } else { printf("%d %d\n", num2, num1); }
We print the smaller number first by comparing num1 and num2 with '<'.
