You are given an array/list ‘BINARYNUMS’ that consists of ‘N’ distinct strings which represent all integers from 0 to N in binary representation except one integer. This integer between 0 to ‘N’ whose binary representation is not present in list ‘BINARYNUMS’ is called ‘Missing Integer’.
Your task is to find the binary representation of that ‘Missing Integer’. You should return a string that represents this ‘Missing Integer’ in binary without leading zeros.
Note
1. There will be no leading zeros in any string in the list ‘BINARYNUMS’.
Example:
Consider N = 5 and the list ‘binaryNums’= [“0”, “01”, “010”, “100”, “101”]. This list consists of the binary representation of numbers [0, 1, 2, 4, 5]. Clearly, the missing number is 3 and its binary representation will be “11”. So you should return string “11”.
Input format:
The first line of input contains an integer ‘T’ denoting the number of test cases. then ‘T’ test cases follow.
The first line contains single integers ‘N’ represent the size of the list ‘BINARYNUMS’.
The second line contains ‘N’ space-separated string representing the list ‘BINARYNUMS’.
Output format :
For each test case, print a single line containing a single string that represents this ‘Missing Integer’ in binary without leading zeros.
The output of each test case will be printed in a separate line.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 50
1 <= N <= 10 ^ 4
Where ‘T’ is the total number of test cases and ‘N’ is the size of list ‘BINARYNUMS’
Time limit: 1 sec.
In this approach, we will create an array of integers ‘nums’, by converting each string present in list ‘binaryNums’ in the integers they represent.
A binary string can be...read more
In this approach, we will create a boolean array ‘present’ of size ‘N + 1’, where present[i] will be true, only if the binary representation of integer ‘i’ is presen...read more
Let ‘xorAll’ be the bitwise xor of all the integers from 0 to ‘N’ and ‘xorNum’ be the bitwise xor of all the integers represented by the strings in the list binaryNum...read more
The number of bits required to represent an integer ‘N’ will be floor(logN) + 1 (log on base 2).
You can observe that number of integers between 0 to N (inclusive) that ha...read more
Top HexaView Technologies Applications Engineer interview questions & answers
Popular interview questions of Applications Engineer
Reviews
Interviews
Salaries
Users/Month