2's Complement
Basic Accuracy: 53.66% Submissions: 239 Points: 1

For a given string of binary number bi. Find the two’s complement of it.

Example 1:

Input: bi = 00000101
Output: 11111011
Explaination: 2's complement is reversing all
the bits of the given number and then adding
1 to it.

Example 2:

Input: bi = 101
Output: 011
Explaination: Follow the process of figuring
out 2's complement. This will be the answer.

You do not need to read input or print anything. Your task is to complete the function complement() which takes bi as input parameter and returns the 2's complement of the number.

Expected Time Complexity: O(|bi|)
Expected Auxiliary Space: O(|bi|)

Constraints:
1 ≤ |bi| ≤ 10

We are replacing the old Disqus forum with the new Discussions section given below.