title: Find Xor of an Array
body: <p>I have an array A of length <code>n</code> and array <code>B</code> of length <code>m</code>. I have to find following below value.</p>
  
  <pre><code> long ans=0;
   for(int i:B)
      {
             xor=0;
             for(int j:A) xor+=j^i;
             ans+=xor
      }
  print ans
  </code></pre>
  
  <p>Time Complexity is <strong>O(N*M</strong>).
  In short I have to find this value</p>
  
  <p><strong><em>(A1^B1+A2^B1+A3^B1+A4^B1+A5^B1.....) +  (A1^B2+A2^B2+A3^B2+A4^B2+A5^B2.....)+  (A1^B3+A2^B3+A3^B3+A4^B3+A5^B3.....)...... so on</em><br></strong>
  How to find this value with better time complexity ? I think  <strong>XOR is not associative</strong> so we can't take the easy way ?</p>