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
# [Problem 2220: Minimum Bit Flips to Convert Number](https://leetcode.com/problems/minimum-bit-flips-to-convert-number/description/?envType=daily-question)
2
2
3
3
## Initial thoughts (stream-of-consciousness)
4
+
- First we need to convert each number to its binary representation. We can do that using `bin(x)[2:]`
5
+
- Next, we need to append leading 0s as needed. We need to append `abs(len(start) - len(goal))` leading 0s to whichever (of `start` or `goal`) has a shorter binary representation
6
+
- Finally, now that the two representations have the same length, we can just loop through bit by bit and count up the number of mismatches
0 commit comments