Pergunta de entrevista da empresa IBM

The question was "How do you swap two values without creating a new variable?"

Respostas da entrevista

Sigiloso

8 de mar. de 2013

I didn't answer the question correctly, but I looked it up later and found it: a = a XOR b b = a XOR b a = a XOR b

4

Sigiloso

17 de ago. de 2018

I liked solution using XOR. We can do it with +/- as well. If we know numbers are less than some integer limits. a= a + b b = a -b a = a- b