I came across this line of code
for (int i = 1; i < nums.length; i++) num ^= nums[i]
What does ^=
mean?
I came across this line of code
for (int i = 1; i < nums.length; i++) num ^= nums[i]
What does ^=
mean?
It is the bitwise XOR operator. Check out this answer for a more in depth explanation.
It's a bitwise XOR operator normally used for """encryption""" it works like this:
A|B|Y 0|0|0 0|1|1 1|0|1 1|1|0
here is an example:
a ^ z 'a' in binary is 01100001 'z' in binary is 01111010 01100001 01111010 00011011 = 27(ESC in ASCII)