Number of 1 Bits
Problem Statement:
Given a positive integer n. Your task is to return the count of set bits.
-
Example:
Examples:
Input:n = 6
Output:2
Explanation:Binary representation is '110', so the count of the set bit is 2.Input: n =8
Output:1
Explanation:Binary representation is '1000', so the count of the set bit is 1.Input: n =3
Output:2
🚀 Level Up Your Engineering Mindset
Never Study in Isolation. Join Binary Dose.
Connect with fellow engineers, clear conceptual doubts, and get 2 visual breakdowns & engineering mental models daily across our community channels.
Official Hub
Discord Community
Start at #welcome-and-rules, say hello in #general-chat, clear doubts, and collaborate with engineers worldwide.