BIT Manipulation
BITMASK - Two varieties of approach Type -1 --> analyze for each bit (for simplicity -> take array as {1 0 0 1 0} types) Practice ke liye => OA wala question + Atcoder Type-2 (See both accepted solutions) BITSET in cpp NOTE - use bitset => binary representation (NOT decimal) Why do we need? Let's say make boolean array of size 1e9 => High time complexity But with bitset, it will automatically break 1e9 into multiple part of each 32 size (bcz 32-bit system) => time = 1e9/32 Can use in case of take/ not take situation bitset<1000> num --> by default, num = 0 bitset<1000> num (x) --> set num = x => x can be number or binary string num.to_string() => converts to string num.to_ullong() => converts to unsigned long long; can access ith bit as num[i] Operations set sets all bits to 1 --> num.set() reset sets all bits to 0 flip toggles ...