You are viewing a single comment's thread. Return to all comments →
O(m+n) solution for javascript
const strings_map = {} for (let el of strings) { if( strings_map[el] == undefined) { strings_map[el] = 1 } else { strings_map[el]++ } } const result = [] for (let q of queries) { let count = 0 if( strings_map[q] == undefined) { count = 0 } else { count = strings_map[q] } result.push(count) } return result
`
Seems like cookies are disabled on this browser, please enable them to open this website
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →
O(m+n) solution for javascript
`