Integer.bitCount() is accepted but
Long.bitCount() doesn't work for 2147483648.
I do not have any idea, could someone please explain?
Please always provide not just the input but also your output and the expected output.
Expected is 1, your output is 33.
Java doesn't have unsigned ints, so you're given a signed int with the same bit pattern instead. I think I saw that said in the problem statement, but it must've been another problem. Anyway, 2147483648 is one 1-bit followed by 31 zeros and thus you actually get -2147483648. Since it's negative, converting it to
long means extending it with 1-bits, so it becomes 33 1-bits (followed by 31 0-bits).