Bit Manipulation, Easy
Question
Write a function that takes an unsigned integer and returns the number of ‘1’ bits it has (also known as the Hamming weight).
Example 1:
|
|
Example 2:
|
|
My Answer
|
|
Running time: O(n), n is the length of the given number, 3ms
Other Answer
|
|
Running time: O(n), n is the length of the given number, 3ms