Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
filter solution in Clear category for [old] Count Inversion by artee2025
"use strict";
function countInversion(s){
return s.map((e,i)=>s.filter((e2,i2)=>(i2>i)&&(e2a+b);
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(countInversion([1, 2, 5, 3, 4, 7, 6]), 3, "Example");
assert.equal(countInversion([0, 1, 2, 3]), 0, "Sorted");
assert.equal(countInversion([99, -99]), 1, "Two numbers");
assert.equal(countInversion([5, 3, 2, 1, 0]), 10, "Reversed");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
April 16, 2018
Comments: