luoheng
10/11/2019 - 1:54 PM

hammingWeight

func hammingWeight(num uint32) int {
    s := 0
    for num != 0 {
        s++
        num &= num - 1
    }
    return s
}