function getSackOutlier(contents) {
const {length} = contents;
const halfLength = length / 2;
const comp1 = contents.slice(0, halfLength);
const comp2 = contents.slice(halfLength);
const items1 = new Set();
const items2 = new Set();
for (let i = 0; i < halfLength; i++) {
if (items2.has(comp1[i])) return comp1[i]
else items1.add(comp1[i]);
if (items1.has(comp2[i])) return comp2[i]
else items2.add(comp2[i]);
}
throw new Error("No matches found!");
}