Is this solution acceptable ?

  • 0
    I was wondering if this solution is acceptable. 	
    I have converted the integer from String to binary and then counted the number of 1's. 
        	char binstr[] = Integer.toBinaryString(n).toCharArray();
    	int count =0;
    	for(int i=0;i<binstr.length;i++) {
    		if(binstr[i] == '1') {
    	return count;

Log in to reply

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