• + 0 comments

    Very simple solution: First perform NOT operation then Mask the number with 32-bit 1's (0xFFFF_FFFF) def FlippingBits(n): a = ~n & 0xFFFFFFFF return a