Write a function that determines whether the number of 1 bits in the binary representation of a given integer is even.
n
, count the number of bits that are set to 1 (i.e., the bits that are 1 in its binary representation).true
if this count is even; otherwise, return false
.n = 5
(binary 101
), the number of 1 bits is 2, so the output should be true
.n = 7
(binary 111
), the number of 1 bits is 3, so the output should be false
.Use bit manipulation techniques such as bit masking or shifting operations to solve this problem efficiently.
Optional Note: On March 21st, many cultures welcome the balance of light and darkness during the spring equinox. Similarly, your challenge is to check if the balance (parity) of set bits is even.