Company: BNY Codedivas 2026
Difficulty: medium
Flip or Flop James challenges his friend Jessica to solve a problem. He gives her an integer array A of size N and asks her to perform an operation in which she can choose any element present in the array, change the element into its binary equivalent and then flip any bit of that element. He also gives her an integer T and allows her to perform the operation as many times as she wants, but she must obtain the bitwise XOR of all the elements in the array equal to T. Your task is to help Jessica find and return an integer value which represents the minimum number of operations required to obtain the bitwise XOR of all the elements of the array equal to T. Note: Assume 1 based indexing. Flipping a bit means converting bit 1 to bit 0, or vice versa. Flipping any bit of any element is counted as one operation. It is guaranteed that there always exists some finite sequence of the above operations on any given array so that the bitwise XOR of all the elements of that array becomes T. Input S