1's Complement
Submissions: 2135   Accuracy:

45.26%

  Difficulty: Basic   Marks: 1

Given an N bit binary number, find the 1's complement of the number. The ones' complement of a binary number is defined as the value obtained by inverting all the bits in the binary representation of the number (swapping 0s for 1s and vice versa).

Input:

The first line of input takes an integer T, the number of test cases. Then T test cases follow. The first line of each test case takes an integer N, the number of bits. The second line of each test case takes N space separated integers denoting the N bits of the binary number.

Output:

Print the 1's complement for each test case in a new line.

Constraints:
1<=T<=100

1<=N<=100

Example:
Input:

3
2
1 0
2
1 1
3
1 0 1

Output:
0 1
0 0 0 1 0

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arpan Kundu
Author: akundusaltlake


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.