Given an array of N integers we have to XOR each element with a certain number such that the resultant XOR is prime and the sum of the resultant XORs is minimum possible.
It is easy to observe that XORing each number with 2(since it is the smallest prime number) which will give us the desired number.
The only exception here being 2 (since XORing it with 2 will result in 0 which is not allowed) thus we XOR all elements with A[i] = 2 with 3.
TIME COMPLEXITY :
The Time complexity is O(N).
using namespace std;