Guest User

Untitled

a guest
Dec 11th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. const inversionCount = array => {
  2. return array.reduce((accumulator, current, index, array) => {
  3. return array
  4. .slice(index)
  5. .filter(item => {
  6. return item < current;
  7. })
  8. .map(item => {
  9. return [current, item];
  10. })
  11. .concat(accumulator);
  12. }, []).length;
  13. };
Add Comment
Please, Sign In to add comment