2 ms·
Here is my solution in JS: "The foo the foo the defenestration the" .split(/\s/) .map(w => w.toLowerCase()) .reduce((m, w) => { m[w] = m[w] ?
by throwaway4good 6y ago
Here is my solution in JS:
"The foo the foo the defenestration the"
.split(/\s/)
.map(w => w.toLowerCase())
.reduce((m, w) => { m[w] = m[w] ? m[w] + 1 : 1; return m }, {})
I haven't checked the performance, though ...
- frankenst1 6y agoOne of the specs is to not read the file in full but to parse it in chunks from stdin. You also need to sort the output by count.