# 2’s Complement

Posted: 18 Feb, 2021

Difficulty: Easy

#### Given a binary string of length ‘N’, find its 2’s complement.

```
A binary string contains only ‘0’ or ‘1’.
2’s complement is 1’s complement + 1.
For example, 2’s complement of 00000101 is 11111011.
```

#### Input format :

```
The first line of input contains an integer T denoting the number of test cases.
The next line contains a string of length N.
```

#### Output format :

```
For each test case, print the 2’s complement of the given string in a separate line.
```

#### Note :

```
You don’t have to print anything; it has already been taken care of. Just implement the given function.
```

#### Constraints :

```
1 <= T <= 5
1 <= N <= 20
where ‘T’ is the total number of test cases, and N is the length of the string.
Time Limit : 1sec
```

Approach 1

Approach 2

SIMILAR PROBLEMS

# Ninja's Frustrating Homework

Posted: 8 Jul, 2021

Difficulty: Ninja

# Find All Subsets

Posted: 23 Jul, 2021

Difficulty: Easy

# Longest Common Prefix

Posted: 24 Jul, 2021

Difficulty: Moderate

# Hotel Rooms

Posted: 29 Jul, 2021

Difficulty: Moderate

# Subset OR

Posted: 31 Jul, 2021

Difficulty: Moderate