Bit Manipulation — Complete Guide
Master bit manipulation: XOR tricks, counting bits, bitmask DP, Brian Kernighan, two's complement, and 5-language operators.
webcoderspeed.com
6 articles
Master bit manipulation: XOR tricks, counting bits, bitmask DP, Brian Kernighan, two's complement, and 5-language operators.
Generate all subsets of an array. Each subset corresponds to a bitmask of n bits where bit i = 1 means element i is included.
Count words that contain puzzle[0] and only letters from puzzle. Encode words as bitmasks, for each puzzle enumerate its subsets containing puzzle[0].
Find max product of lengths of two words with no common letters. Encode each word as bitmask; two words share letters if AND != 0.
Count substrings with at most one odd-frequency letter using bitmask prefix XOR and a hash map.
Master bitwise operations for DSA: XOR tricks, Brian Kernighan bit counting, subset enumeration, and bitmask DP.