https://leetcode.com/problems/number-of-1-bits Easy

Решение

class Solution {
    fun hammingWeight(n: Int): Int {
        var x = n
        var c = 0
        while (x != 0) {
            x = x and (x - 1)
            c++
        }
        return c
    }
}