DEV Community

Discussion on: Terrible interview question: Swap variables without a temporary

Collapse
 
geocine profile image
Aivan Monceller

[x , y] = [y , x]

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

I'm sure you'd immediately get a red card, "oh, but not that way!" :/

"And not that way..."

"Also not that way..."

"Stop problem solving and just figure out the thought I have in my head!"

Collapse
 
geocine profile image
Aivan Monceller

This is what comes to mind unfortunately as you said on your post. However, it would probably make us clever if we ask, Do you want to swap only unsigned integers or any type of variable?