0
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. https://code.sololearn.com/cz48RGbfJxmb/?ref=app
4 ответов
+ 2
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 .
+ 1
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.
+ 1
You can understand this code here is my try:
https://code.sololearn.com/crqn7demaUbT/?ref=app
0
Hey Abhay
The result of XOR is 1 if the two bits are different.