Exercises/#82 Number of 1 Bits (Hamming Weight)
#82

Number of 1 Bits (Hamming Weight)

Easy⚡ Bit Manipulation
40 XP

Problem

Write a function that takes an unsigned integer and returns the number of '1' bits (Hamming weight).

Examples

Input: n=00000000000000000000000000001011
Output: 3

Input: n=11111111111111111111111111111101
Output: 31
bit-manipulation
AI Assistant— powered by AI

Unlock hints progressively — start gentle, go deeper only if needed.

💡

Level 1: Gentle Nudge

A subtle direction

🗺️

Level 2: Approach

The algorithm to use

🔍

Level 3: Detailed

Step-by-step guidance

82 / 150

Your Solution

⚡ JavaScript

to save progress and use AI features