0 ms C Solution, with interesting problem


  • 0
    S

    0 ms C Solution, with interesting problem

    Question: code run into problem if instead of +=, write result = result + ... anyone have an answer?


    int hammingWeight(uint32_t n) {
    int result = 0;
    for(int i = 0; i<32; i++){
    result += (n >> i) & 1;
    }
    return result;
    }



Log in to reply
 

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