Why this solution is failing ?


  • -1
    A

    "public int hammingWeight(int n) {
    int i=0;
    for(i=0;n>0;n=(n&(n-1)), i++);
    return i;
    }"

    Please tell if this solution is correct? If not why ?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.