#3226
Number of Bit Changes to Make Two Integers Equal
pupil · 355 · lc easy +23 · 63.4% accepted · 103 likes · top 66%
Description
You are given two positive integers n and k. You may flip any 1-bit in n's binary representation to 0.
Return the minimum number of flips to make n == k, or -1 if impossible.
Code
1
2
3