How to work with negative nos using bitmasking

getting wrong no on negative input.

hi @coder_girl
try submitting this code -->

No ,Its not working.
please check for this input
10
-2 -2 1 1 4 1 4 4 -4 -2
Output should be -4
but getting 0.

hi @coder_girl
This bitwise method is not applicable for negative numbers. For negative numbers u can use other methods like maintaining frequency and then computing ans…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.