Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Native solution in Clear category for [old] Median by bryukh
"use strict";
function median(array) {
const arrayLength = array.length;
const sorted = array.sort((a, b) => a - b);
if (arrayLength % 2) {
return sorted[(arrayLength-1)/2];
} else {
return (sorted[arrayLength/2] + sorted[arrayLength/2-1]) / 2;
}
}
June 27, 2016
Comments: