Here are bit manipulation patterns you will see repeatedly in interviews and production code.
Check if is even: .
Set the -th bit: .
Clear the -th bit: .
Toggle the -th bit: .
Check if is a power of 2: and .
These tricks replace loops with single operations. Instead of checking divisibility by 2, you check the last bit. Instead of looping to set a bit, you use OR with a mask. Memorize these patterns.