HTMLify
LootCode - Minimum Bit Flips to Convert Number - Python
Views: 301 | Author: abh
1 2 3 4 5 6 7 8 9 10 | class Solution: def minBitFlips(self, start: int, goal: int) -> int: bb = len(bin(max([start, goal]))) - 2 sb = bin(start)[2:].zfill(bb) gb = bin(goal)[2:].zfill(bb) d = 0 for i in range(bb): if sb[i] != gb[i]: d += 1 return d |