Qualcomm Interview Question
Software Engineer in TestsThe most simple algorithm for the above problem is to follow the steps below:
1. First, we will take the xor of the two numbers such that the first number remains in the first variable itself.
2. We will then, take xor of the two numbers again which will put the first number in the second variable also, and then finally take xor so that the second number comes to the first variable
Implementation:
a = a^b;
b = a^b;
a = a^b;
a=a^b
- Anonymous October 08, 2010b=a^b
a=a^b