Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const inversionCount = array => {
- return array.reduce((accumulator, current, index, array) => {
- return array
- .slice(index)
- .filter(item => {
- return item < current;
- })
- .map(item => {
- return [current, item];
- })
- .concat(accumulator);
- }, []).length;
- };
Add Comment
Please, Sign In to add comment