Jump Trading interview question

Swap two variables without using a temp.

Interview Answers

Anonymous

Sep 19, 2012

in c/c++: x^=y^=x^=y;

4

Anonymous

Feb 11, 2016

a= a*b; b = a/b; a = a/b;

2

Anonymous

Nov 24, 2017

+/- is correct even with overflow

Anonymous

Nov 8, 2012

You don't want to use +-/* as you might face under/overflow.

Anonymous

Apr 11, 2012

Can be done using adding/subtracting, multiply/divide, xor.