terminal
Elevo
/
ESC
Login
Initiate Registration
code
Topics
corporate_fare
Companies
history
History
arrow_back
Back to Challenges
#191
Number of 1 Bits
Easy
Acceptance 0%
Editorial
description
Problem Description
Write a function that takes the binary representation of a positive integer and returns the number of set bits it has (also known as the Hamming weight).
checklist
Constraints
1 <= n <= 2^31 - 1
science
Examples
Case #1
In:
n = 11
Out:
3
Case #2
In:
n = 128
Out:
1
Mastery Tags
Bit Manipulation
Hiring Companies
Amazon
Apple
Microsoft
code
Integrated IDE
Python 3
expand_more
C
C++ 17
Java
JavaScript
Python 3
C
C++ 17
Java
JavaScript
Python 3
refresh
class Solution: def hammingWeight(self, n: int) -> int: pass
Login to Compile
Processing
terminal
Debug Output
home
Home
extension
Practice
robot_2
login
Sign In
account_circle
Menu
code_blocks
Coding
psychology
Aptitude
Navigation
close
Login
Registration