I came across this post, which reports the following interview question:
Given two arrays of numbers, find if each of the two arrays have the same s
why not i find the sum , product , xor of all the elements one array and compare them with the corresponding value of the elements of the other array ??
the xor of elements of both arrays may give zero if the it is like
2,2,3,3 1,1,2,2
but what if you compare the xor of the elements of two array to be equal ???
consider this
10,3 12,5
here xor of both arrays will be same !!! (10^3)=(12^5)=9 but their sum and product are different . I think two different set of elements cannot have same sum ,product and xor ! This can be analysed by simple bitvalue examination. Is there anything wrong in this approach ??