728x90
Above is the link to the problem.
Problem
Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).
Example
Input: n = 00000000000000000000000000001011
Output: 3
Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits.
Code
This code gets the 10.73% of time complexity and uses 13.9MB of memory.
728x90
반응형
'Code > LeetCode' 카테고리의 다른 글
[LeetCode] 202. Happy Number (Easy/Python) (0) | 2023.03.05 |
---|---|
[LeetCode] 28. Find the Index of the First Occurrence in a String (Medium/Python) (0) | 2023.03.03 |
[LeetCode] 190. Reverse Bits (Easy/Python) (0) | 2023.01.15 |
[LeetCode] 134. Gas Station (Medium/Python) (0) | 2023.01.14 |
[LeetCode] 1833. Maximum Ice Cream Bars (Medium/Python) (0) | 2023.01.08 |