Number whose XOR sum with given array is a given number k | This function returns the number to be inserted in the given array ; initialise the answer with k ; ans ^= A [ i ] XOR of all elements in the array ; Driver Code
def findEletobeInserted ( A , n , k ) : NEW_LINE INDENT ans = k NEW_LINE for i in range ( n ) : NEW_LINE return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = [ 1 , 2 , 3 , 4 , 5 ] NEW_LINE n = len ( A ) NEW_LINE k = 10 NEW_LINE print ( findEletobeInserted ( A , n , k ) , " has ▁ to ▁ be ▁ inserted ▁ in ▁ the ▁ given " , " array ▁ to ▁ make ▁ xor ▁ sum ▁ of " , k ) NEW_LINE DEDENT