Skip to main content

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

💬

Discussion & Doubts