191. Number of 1 Bits
題目原文
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:
解題思路
我的解法比較像是韌體工程師的想法。
當作是shift的方式移動32bit register 。
判斷lsb bit為0/1,如果是1把ans + 1。
程式解答
Last updated
Was this helpful?