Glossary: Coding Interviews in JavaScript
Hash map lookup and counting
Also written: hash map, hash map lookup
Pattern 1: use a `Set` to ask 'have I seen this?' in O(1), or a `Map` to count how many of each item. It costs O(n) time and space.
Glossary: Coding Interviews in JavaScript
Also written: hash map, hash map lookup
Pattern 1: use a `Set` to ask 'have I seen this?' in O(1), or a `Map` to count how many of each item. It costs O(n) time and space.