解题思路
相关代码
class Solution {public String baseNeg2(int n) {if(n==0) return "0";String s="";while(n!=0)if(Math.abs(n)%2==0){n=n/(-2);s=s+'0';}else{s=s+'1'; n = (n-1)/(-2);}String t = reverse(s);return t;}public String reverse(String s){String t="";for(int i=0;i<s.length();i++) t = s.charAt(i)+ t;return t;}
}