'JAVA Bitwise XOR modulo

I have to perform bitwise XOR on array of integers and then Return the answer modulo 998244353. I have solved the first part but I have got stuck in 2nd part. I searched on the internet but couldn't find anything useful for this kind of combination of xor operator and modulo. Please help.



Solution 1:[1]

Try doing the modulo operation on each iteration,

for(int i=0; i<arr.length; i++)
{
    result = (result ^ arr[i])%998244353;
}
return result%998244353;

So that, it will reduce the number if the number is greater than 998244353.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sai Teja Polisetty