Algorithm: find the missing element from 2 given arrays, second array is duplicate
<p>Find the missing element from the given 2 arrays, second array is duplicate.</p>

<p>Example:
array 1: [1,2,3,4,5,6,7] 
array 2: [1,3,4,5,6,7]</p>

<p>I read about using hashmaps and other complex approaches, but I believe the best solution is:</p>

<p>1) Add all elements of array1 and array2 separately, such that we have sum1 and sum2, then the answer is |sum2 - sum1|</p>

<p>2) XOR all elements of array1 and array2 separately, such that we have xor1 and xor2. Here xor1 is always from the complete array. The missing element will be xor2 XOR xor1 (from XOR applications <a href="http://www.codeproject.com/Articles/2983/XOR-tricks-for-RAID-data-protection" rel="nofollow">http://www.codeproject.com/Articles/2983/XOR-tricks-for-RAID-data-protection</a>)</p>

<p>Edit: arrays not sorted</p>

<p>Am I correct?</p>