XOR of 2 numbers without using XOR operator

preview_player
Показать описание
This video explains a very tricky and interesting interview question which is how to find XOR between 2 numbers without using the XOR operator. This sounds confusing but its very simple and has many possible solutions. The most efficient solution is explained at the end of the video. If you have any alternate solution then do comment below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

Рекомендации по теме
Комментарии
Автор

i think this is same as we know from Digital electronics
a XOR b = (~a AND b) OR (a AND ~b)

spetsnaz_
Автор

sir, can i also use this equation .

a+b=a^b+2*(a&b)
=> a^b=a+b - 2*(a&b)

sonusingh-hjdw
Автор

Shouldn't it be (~x | ~y) & (x | y) ??
Or (~x | ~y) && (x | y) is fine ??

kesharkashyap
Автор

Hi @tech Dose - Nice explanation!! can you please share the theory behind (~x | ~y) & ( x|y). This will help to solve other problems as well

jankeshchakravarthy
Автор

what would be the time complexity of 1st method??

palakgupta
Автор

what about when we have carry from the previous 1 1

ShivamSingh-smoy
Автор

Don't we need &(Bit-wise) rather than &&(logical) in the efficient solution.

rajeevsawant
join shbcf.ru