Here's a quick reference of the most useful bit tricks:
• Power of 2 check: and
• Clear rightmost set bit:
• Isolate rightmost set bit:
• Count set bits: loop with
• Find unique element (all others appear twice): XOR all numbers
• Generate all subsets: iterate masks from to
Memorize these patterns. They appear frequently in coding interviews.