DEV Community

loading...

Discussion on: Daily Challenge #256 - How Many Are Smaller Than I?

Collapse
jpantunes profile image
JP Antunes

Simple JS solution.

const smaller = arr => arr.reduce((acc, val, idx) => {
    acc[idx] = arr.filter((e, i) => e < val && i > idx).length;
    return acc;
},[]);