maybe fewest operations
Spread the highest 1-bit onto all the lower bits. Then xor with that.\n\nint findComplement(int num) {\n    int mask = num;\n    mask |= mask >> 1;\n    mask |=
Spread the highest 1-bit onto all the lower bits. Then xor with that.\n```\nint findComplement(int num) {\n    int mask = num;\n    mask |= mask >> 1;\n    mask |= mask >> 2;\n    mask |= mask >> 4;\n    mask |= mask >> 8;\n    mask |= mask >> 16;\n    return num ^ mask;\n}\n```
[]