Class Solution
java.lang.Object
g1001_1100.s1017_convert_to_base_2.Solution
1017 - Convert to Base -2.<p>Medium</p>
<p>Given an integer <code>n</code>, return <em>a binary string representing its representation in base</em> <code>-2</code>.</p>
<p><strong>Note</strong> that the returned string should not have leading zeros unless the string is <code>"0"</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 2</p>
<p><strong>Output:</strong> “110” <strong>Explantion:</strong> (-2)<sup>2</sup> + (-2)<sup>1</sup> = 2</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 3</p>
<p><strong>Output:</strong> “111” <strong>Explantion:</strong> (-2)<sup>2</sup> + (-2)<sup>1</sup> + (-2)<sup>0</sup> = 3</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> n = 4</p>
<p><strong>Output:</strong> “100” <strong>Explantion:</strong> (-2)<sup>2</sup> = 4</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= n <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
baseNeg2
-