Share my Java Code


  • 0
    Z
     String str=Integer.toUnsignedString(n,2);
        
        StringBuilder sb=new StringBuilder();
           for(int i=str.length(); i<32;i++){
        	   sb.append("0");
           }
    	    
           sb.append(str);
           
         return (int)  Integer.parseUnsignedInt(sb.reverse().toString(),2);

  • 3
    E

    haha, Integer.reverse(n) is more simple.


Log in to reply
 

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