|
|
|
@ -17,7 +17,7 @@ Some helpful utility snippets:
|
|
|
|
|
- Set k<sup>th</sup> bit: `num |= (1 << k)`.
|
|
|
|
|
- Turn off k<sup>th</sup> bit: `num &= ~(1 << k)`.
|
|
|
|
|
- Toggle the k<sup>th</sup> bit: `num ^= (1 << k)`.
|
|
|
|
|
- To check if a number is a power of 2, `num & num - 1 == 0` or `num & (-num) == num`.
|
|
|
|
|
- To check if a number is a power of 2, `(num & num - 1) == 0` or `(num & (-num)) == num`.
|
|
|
|
|
|
|
|
|
|
## Corner cases
|
|
|
|
|
|
|
|
|
|