1// Find the odd int
2function findOdd(A) {
3 return A.reduce((a, b) => a ^ b);
4}
5
6console.log(findOdd([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5], 5)); // 5
7console.log(findOdd([1,1,2,-2,5,2,4,4,-1,-2,5], -1)); // -1
8console.log(findOdd([20,1,1,2,2,3,3,5,5,4,20,4,5], 5)); // 5
1function findOdd(A) {
2 let counts = A.reduce((p, n) => (p[n] = ++p[n] || 1, p), {});
3 return +Object.keys(counts).find(k => counts[k] % 2) || undefined;
4}