How can you swap 2 variables?
Anónimo
Instead of doing a naive solution that requires a third temporary variable and thus wastes memory, utilize a bit-wise XOR operator to swap the variables in place. X = X ^ Y -> Y = X ^ Y -> X = X^Y. After the third line X and Y's data should be swapped.