Loading...
Engaged employer
swap two numbers without using temporary variable
Anonymous
b=a+b; a=b-a; b=b-a;
Sagar's answer is decent, but there might be problems if they consider overflow. Better is using xor: b = a XOR b a = a XOR b b = a XOR b
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalised job recommendations and updates by starting your searches.