mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
35 lines
1002 B
HTML
35 lines
1002 B
HTML
<p>给出数字 <code>N</code>,返回由若干 <code>"0"</code> 和 <code>"1"</code>组成的字符串,该字符串为 <code>N</code> 的<strong>负二进制(<code>base -2</code>)</strong>表示。</p>
|
||
|
||
<p>除非字符串就是 <code>"0"</code>,否则返回的字符串中不能含有前导零。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>2
|
||
<strong>输出:</strong>"110"
|
||
<strong>解释:</strong>(-2) ^ 2 + (-2) ^ 1 = 2
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>3
|
||
<strong>输出:</strong>"111"
|
||
<strong>解释:</strong>(-2) ^ 2 + (-2) ^ 1 + (-2) ^ 0 = 3
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>4
|
||
<strong>输出:</strong>"100"
|
||
<strong>解释:</strong>(-2) ^ 2 = 4
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ol>
|
||
<li><code>0 <= N <= 10^9</code></li>
|
||
</ol>
|