Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Algorithms/Utils/Swap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ The swap algorithm takes 2 variables, and swap the values of them so that finall
## Tips
- Use `SwapNum` for keeping memory footprint to minimum.

## Swap number using Bitwise XOR Operator

function swapByXOR(a,b):
a = a ^ b # set bits, either set in a or b, store it in a
b = a ^ b # set bits which were set in original a, store it in b
a = a ^ b # set bits which were set in original b, store it in a