ktongue's picture
download
raw
518 Bytes
import appearance from "./appearance.js";
import {sum} from "./ascending.js";
export default function(series) {
var n = series.length,
i,
j,
sums = series.map(sum),
order = appearance(series),
top = 0,
bottom = 0,
tops = [],
bottoms = [];
for (i = 0; i < n; ++i) {
j = order[i];
if (top < bottom) {
top += sums[j];
tops.push(j);
} else {
bottom += sums[j];
bottoms.push(j);
}
}
return bottoms.reverse().concat(tops);
}

Xet Storage Details

Size:
518 Bytes
·
Xet hash:
9a4112457508dcb2251da1af60d209c0e33b1a7a2bca6b02f1c46fd485a8271b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.