Re: [闲聊] 每日leetcode

楼主: dont   2024-09-11 12:12:25
2220. Minimum Bit Flips to Convert Number
## 思路
检查XOR之后的bit数
## Code
```python
class Solution:
def minBitFlips(self, start: int, goal: int) -> int:
res = 0
num = start ^ goal
while num:
res += 1
num &= num-1
return res
```
1318. Minimum Flips to Make a OR b Equal to c
## 思路
检查a,b,c的bit
c=1

Links booklink

Contact Us: admin [ a t ] ucptt.com