solution

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 1 Imported by: 0

README

1017. Convert to Base -2

[中等] 数学


给出数字 N,返回由若干 "0" 和 "1"组成的字符串,该字符串为 N 的负二进制(base -2)表示。

除非字符串就是 "0",否则返回的字符串中不能含有前导零。

 

示例 1:

输入:2
输出:"110"
解释:(-2) ^ 2 + (-2) ^ 1 = 2


示例 2:

输入:3
输出:"111"
解释:(-2) ^ 2 + (-2) ^ 1 + (-2) ^ 0 = 3


示例 3:

输入:4
输出:"100"
解释:(-2) ^ 2 = 4


 

提示:


	0 <= N <= 10^9


Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL