it’s XOR operator (exclusive OR op.):
will toggle (invert) the bit of an operand in position where any bit having value 1 in the other operand
int ans = a[i]^1;
e.g. a 4 byte size, at an i:
a[i] = 00000000 0000000 1000000 1000001
1 = 00000000 0000000 0000000 0000001
---------------------------------- XOR
00000000 0000000 1000000 1000000
^ --> 1st bit of a[i] get toggled