arrow_back Back to Challenges

#191 Number of 1 Bits

Easy Acceptance 0%
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

code_blocks
Coding
psychology
Aptitude