Skip to content

Instantly share code, notes, and snippets.

@giannispan
Created February 1, 2016 17:16
Show Gist options
  • Save giannispan/20b483cb7c6f6a643fdd to your computer and use it in GitHub Desktop.
Save giannispan/20b483cb7c6f6a643fdd to your computer and use it in GitHub Desktop.
Find The Parity Outlier
function findOutlier(integers){
var length = integers.length, i;
var evens = [];
var odds = [];
var k
for (i=0; i<length; i++) {
if (integers[i] % 2 == 0) {
evens.push(integers[i]);
}
if (Math.abs(integers[i] % 2) == 1) {
odds.push(integers[i]);
}
}
if (evens.length > odds.length)
return odds[0];
else
return evens[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment