You are viewing a single comment's thread. Return to all comments →
javascript
function freqQuery(queries) { let map = new Map(), result = [] for (let [op, val] of queries) { switch (op) { case 1: { map.has(val) ? map.set(val, map.get(val) + 1) : map.set(val, 1) break } case 2: { if (map.has(val) && map.get(val) > 0) map.set(val, map.get(val) - 1) break } case 3: { if ([...map.values()].includes(val)) result.push(1) else result.push(0) } } } return result }
Seems like cookies are disabled on this browser, please enable them to open this website
Frequency Queries
You are viewing a single comment's thread. Return to all comments →
javascript