Learn JavaScript

Lesson 6 of 9 ¡ Map, Set, WeakMap, Iterators, Generators and Regular Expressions

Module 16 ¡ Map, Set, WeakMap, Iterators, Generators and Regular Expressions

The Contest and Interview Pack: Four Patterns, Six Questions and a Gallery of Collection and Regex Bugs

ProReading

Contest problems and interviews keep coming back to the same handful of ideas. "Count how often each thing appears" is a Map. "Have I seen this already?" is a Set. "Which items share a property?" is a Map of Sets. "Find the first arrangement that works" is a generator you stop early. Each pattern below comes with a solved problem, small enough to type during a contest.

Checking what this lesson needs for youâ€Ļ

What is inside The Contest and Interview Pack: Four Patterns, Six Questions and a Gallery of Collection and Regex Bugs

  1. Pattern 1: counting with a Map
  2. Pattern 2: seen-before with a Set
  3. Pattern 3: a Map of Sets as an index
  4. Pattern 4: a lazy generator search
  5. Escaping text before it becomes a regex
  6. Six interview questions