Number of Bit Changes
Given two positive integers n and k, determine how many set bits (1s) in n must be flipped to 0 to turn n into k. You may only flip 1s to 0s, never 0s to 1s. Return the minimum number of flips needed, or -1 if impossible.
Given two positive integers n and k, determine how many set bits (1s) in n must be flipped to 0 to turn n into k. You may only flip 1s to 0s, never 0s to 1s. Return the minimum number of flips needed, or -1 if impossible.