DEV Community

loading...

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

Collapse
miketalbot profile image
Mike Talbot

const smaller = arr => arr.reduce((c,a,i)=>{
   for(let j =0; j < i; j++) { 
       c[j] = (c[j] || 0) + arr[j] > a ? 1 : 0 
   }
   return c
}, [])