contents(algo): fix typo and suggestions (#272)

This commit is contained in:
jomosz
2022-05-14 11:02:26 +12:00
committed by GitHub
parent d90f358311
commit 87a923079d
7 changed files with 9 additions and 9 deletions

View File

@ -50,7 +50,7 @@ Some helpful utility snippets:
| Set k<sup>th</sup> bit | <code>num &#124;= (1 << k)</code> |
| Turn off k<sup>th</sup> bit | `num &= ~(1 << k)`. |
| Toggle the k<sup>th</sup> bit | `num ^= (1 << k)`. |
| Multiple by 2<sup>k</sup> | `num << k` |
| Multiply by 2<sup>k</sup> | `num << k` |
| Divide by 2<sup>k</sup> | `num >> k` |
| 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` |