A test case gives an integer which is out of range


  • 0
    S

    public class Solution {
    public int hammingWeight(int n) {
    int num=0;
    while(n!=0){
    num+=n%2;
    n/=2;
    }
    return num;
    }
    }

    and the test case is 2147483648


Log in to reply
 

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