Please explain findOdd function in detail | Sololearn: Learn to code for FREE!


Please explain findOdd function in detail

Below program is to find the odd occurring number i.e odd time occurred number. I don't understanding execution of findOdd function. Please explain step by step.

1/27/2021 11:53:47 AM

Giriraj Yalpalwar

4 Answers

New Answer


Xor operation outputs 1 for operands with bit value 1 and 1 and outputs 0 for (1 and 0) and (0 and 0). Bit representation of 12 is 0001100 If you take another repeating number and perform xor operation between them , for example : 12=>0001100 12=>0001100 Output will be 0000000 So if you see , xor operation nulls repeated numbers ,thereby leaving non repeating number .


Thirt13n I know that and that's what keep the original bit alive. You are not messing with that bit . but wait for others answer.


You can understand this code here is my try:


Hey Abhay The result of XOR is 1 if the two bits are different.