Jump Trading

www.jumptrading.com

Interview Question

Software Developer Intern Interview Chicago, IL

Swap two variables without using a temp.

Answer

Interview Answer

3 Answers

0

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

Interview Candidate on Apr 11, 2012
0

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

AlexB on Sep 18, 2012
0

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

HC on Nov 7, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.