💡
Bit Manipulation
Counting bits, XOR tricks, powers, masks.
01
Counting & complement
0/16 of 25Hamming weight, counting bits, complement.
○Is Bit SetSilver · 1000○Number of 1 BitsSilver · 1020○Set BitSilver · 1050○Number ComplementSilver · 1050○Hamming WeightSilver · 1050○Counting Bits 0 to NSilver · 1050○Clear BitSilver · 1100○Prime Number of Set BitsSilver · 1100○Set Bit at IndexSilver · 1130○Find ComplementSilver · 1150○Clear Bit at IndexSilver · 1160○Counting Bits ArraySilver · 1180○Complement of Base 10 IntegerSilver · 1200○Get Nth BitGold · 1300○Complement of NumberGold · 1300○Lowest Set Bit ValueGold · 1300+ 9 more in the arena →
02
XOR tricks
0/16 of 24Single/missing number, XOR of range, subsets.
○Decode the XORed ArraySilver · 1180○Swap Without TempGold · 1300○Decode XORed ArrayGold · 1300○Sum of Subset XOR TotalsGold · 1300○XOR of RangeGold · 1300○XOR of All ElementsGold · 1330○XOR Prefix QueriesGold · 1330○XOR Operation in ArrayGold · 1340○Missing NumberGold · 1350○XOR Queries of a SubarrayGold · 1400○Count Pairs with XOR in RangeGold · 1420○XOR of All Pairwise XORsGold · 1420○Single Number IIGold · 1450○XOR of a RangeGold · 1460○Single Number (Others Thrice)Gold · 1500○Duplicate and Missing via XORGold · 1500+ 8 more in the arena →
03
Powers & distance
0/7Power of two/three/four, hamming distance, gray.
04
Counting & combos
0/11Prime set bits, steps to zero, flips, max xor.
○Number of Steps to Reduce to ZeroSilver · 1020○Minimum Bit Flips to ConvertSilver · 1100○Binary Watch TimesSilver · 1150○Minimum Flips for a OR b == cGold · 1350○Minimum Bit FlipsGold · 1350○Steps to Reduce Binary to OneGold · 1400○Binary Watch CountGold · 1480○Min Flips to Make OR EqualGold · 1550○Largest Combination With Bitwise ANDPlatinum · 1700○Concatenation of Binary NumbersPlatinum · 1850○Min Flips For ORPlatinum · 1850