标签:
题目地址:https://leetcode.com/problems/number-of-1-bits/
解答:
public class Solution { // you need to treat n as an unsigned value public int hammingWeight(int n) { int count = 0; while(n!=0){ count++; n&=(n-1); } return count; } }
标签:
原文地址:http://www.cnblogs.com/xiongyuesen/p/4398797.html