Frage im Vorstellungsgespräch bei Bank of America

Swap two numbers while not using the temp variable.

Antworten zu Vorstellungsgespräch

Anonym

27. Sept. 2013

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

7

Anonym

10. März 2013

using the XOR operator

3

Anonym

4. Feb. 2015

a = a ^ b b = a ^ b a = a ^ b This will avoid over flows which might come in addition steps