Company: JPMC_8_jan
Difficulty: medium
Maximize XOR Result Problem Description Given a binary string x , generate another binary string y of the same length that maximizes the result when XORed with x . The constraint is that the number of bits set to 1 in y cannot exceed maxSet . Return the binary string y . Note: The binary strings will always have bits digits (an integer), and leading zeros are fine. Example Input: bits = 3 maxSet = 1 x = "101" Output: "010" Explanation: First, determine all possible 3-digit binary strings for y with maxSet = 1 or fewer bits set: "000" , "001" , "010" , "100" . These are the potential y values. Now, XOR each of the y-values with x = "101" : 000 XOR 101 = 101 001 XOR 101 = 100 010 XOR 101 = 111 100 XOR 101 = 001 The third value produces the maximal result (111), where y = "010" . Return the string "010" . Function Description Complete the function findYValue in the editor with the following parameter(s): int bits : the length of the binary strings x and y int maxSet : the number of bits t