131. Leetcode 191. 位1的个数 (位运算-汉明距离相关题目)
生活随笔
收集整理的這篇文章主要介紹了
131. Leetcode 191. 位1的个数 (位运算-汉明距离相关题目)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
class Solution:def hammingWeight(self, n: int) -> int:count = 0while n != 0:n = n & (n-1)count += 1return count
?
總結
以上是生活随笔為你收集整理的131. Leetcode 191. 位1的个数 (位运算-汉明距离相关题目)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 129. Leetcode 202. 快
- 下一篇: 位运算知识点