You are viewing a single comment's thread. Return to all comments →
That oneliner kind of works, but it's extremely slow because it recalculates Math.max(ar) for every single item.
You can avoid that by storing the value of Math max like this:
const birthdayCakeCandles = a => (f => a.filter(v => v === f).length)(Math.max(...a));
That way it's still short, but also blazing fast. (Math max is implicitly stored as f here).
f
Seems like cookies are disabled on this browser, please enable them to open this website
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
That oneliner kind of works, but it's extremely slow because it recalculates Math.max(ar) for every single item.
You can avoid that by storing the value of Math max like this:
That way it's still short, but also blazing fast. (Math max is implicitly stored as
f
here).