diff --git a/contents/algorithms/binary.md b/contents/algorithms/binary.md index c11dd1f3..fa4ee73a 100644 --- a/contents/algorithms/binary.md +++ b/contents/algorithms/binary.md @@ -18,6 +18,7 @@ Some helpful utility snippets: - Turn off kth bit: `num &= ~(1 << k)`. - Toggle the kth bit: `num ^= (1 << k)`. - To check if a number is a power of 2, `(num & num - 1) == 0` or `(num & (-num)) == num`. +- Swapping two variables: `num1 ^= num2; num2 ^= num1; num1 ^= num2` ## Corner cases