The same coding is working in Eclipse ,but her getting Wrong Answer


  • 0
    G

    public class CountingNoOfBits {

    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    
    	int count=0;
    

    long n= 2147483648L;
    String binary="";
    long rem=0;
    while(n>0){
    rem=(n%2);
    if(rem==1) count++;
    binary=rem+binary;
    n=n/2;

    	}
    System.out.println(binary);
    System.out.println(count);
    }
    

    }


Log in to reply
 

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