Convert to Base -2 asks you to represent a nonnegative integer as a binary string whose place values are powers of negative two, rather than the usual positive base.
Statement
Given an integer n, return a binary string representing its value in base −2.
Constraints:
0≤n≤109
Examples
Fetching Slides...
Understand the problem
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Convert to Base -2
1.
What is the base ( -2 ) representation for the input 0?
A.
1
B.
10
C.
0
D.
00
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence
1
2
3
4
5
Try it yourself
Implement your solution in the following coding playground.
Convert to Base -2 asks you to represent a nonnegative integer as a binary string whose place values are powers of negative two, rather than the usual positive base.
Statement
Given an integer n, return a binary string representing its value in base −2.
Constraints:
0≤n≤109
Examples
Fetching Slides...
Understand the problem
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Convert to Base -2
1.
What is the base ( -2 ) representation for the input 0?
A.
1
B.
10
C.
0
D.
00
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence
1
2
3
4
5
Try it yourself
Implement your solution in the following coding playground.