You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To minimize the sum, we want to flip the rightmost 0 bits. So we can iterate over the bits of every numbers, and then greedily takes the k rightmost bits.
I also cheesed it a bit by considering 32 bits for all numbers, and all bits left of the last one bit are also zeroes.