11: Hamming weight

Write a method that counts the number of 1 in binary representation uinit value

 

Example 1

Input: 3

Output: 2

Explanation: 3 has two 1 bits (00000000 00000000 00000000 00000011)

Example 2

Input: 10

Output: 2

Explanation: 10 has two 1 bits (00000000 00000000 00000000 00001010)

Difficulty:Easy
Topic:Bit manipulation
Problem #:11