Qualcomm interview question

Swapping integers without using additional space

Interview Answers

Anonymous

May 3, 2012

a= a(xor)b, b= a(xor)b, a=a(xor)b

7

Anonymous

Jul 24, 2012

a = a + b; b = a - b; a = a - b;

1

Anonymous

Jul 24, 2012

Doesn't work if a and b are 32 bit integer. We might have over flow in a+b. a(xor)b will not have any overflow

1