Find the missing element in an unsorted array where every element?
appears twice except one
public int SingleNumber(int[] nums) {
int result = 0;
foreach (var num in nums) {
result ^= num;
return result;
Explanation:
XOR of all elements cancels duplicates, leaving the single unique element.