This is a verified interview question from Wipro. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Find the Transformation String" covers key patterns like Strings.
"The company chooses two gates, gateA and gateB, each containing N number of binary strings in their output. To make the gateA-output similar to gateB, they need to find a binary string T such that when XOR of T with each string in gateA output is performed, then the gateB output is similar to that of gateA. If no such string T is possible, then output a blank string. ### Problem Write an algorithm to help the company find the string T. If no such string is possible, then output a blank string. If there are multiple strings with the minimum number of 1s, output the lexicographically smallest string. If there are multiple strings with the same number of 1s and the same lexicographical order, output any one of them. ### Input The first line of the input consists of an integer `num_gates` representing the number of gates. The second line consists of an integer `num_A` representing the number of strings in gateA output (N). The third line consists of `num_A` space-separated binary strings representing the outputs of gateA. The last line consists of `num_B` space-separated binary strings representing the number of strings in gateB output (num_B is equal to N). ### Output Print a string representing the required binary string T. If no such string is possible, print an empty string. ### Constraints - 1 ≤ num_gates ≤ 1000 - All the binary strings of both sets are equal in length. - All the strings of both gates are unique. - A binary string consists of only 0s and 1s."
Join thousands of developers practicing for Wipro.