6 ms·
Another way is to just use subtraction: x = x + y y = x - y x = x - y I originally learned about this while preparing for some interviews. The funny th
by pdiddy 11y ago
Another way is to just use subtraction:
x = x + y
y = x - y
x = x - y
I originally learned about this while preparing for some interviews.
The funny thing, I find, is that in Python you can simply do this:
x, y = 5, 10
x, y = y, x
I was asked this question in an interview and I responded that you can do this. His response: "Python is weird."