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

27th Jan 2021, 11:53 AM
Giriraj Yalpalwar
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 .
27th Jan 2021, 12:05 PM
Abhay
+ 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.
27th Jan 2021, 12:26 PM
Abhay
+ 1
You can understand this code here is my try: https://code.sololearn.com/crqn7demaUbT/?ref=app
27th Jan 2021, 12:51 PM
0
Hey Abhay The result of XOR is 1 if the two bits are different.
27th Jan 2021, 12:23 PM
Giriraj Yalpalwar
Актуальное сегодня
HELP ME