Learn JavaScript

Lesson 6 of 9 · Strings and Template Literals

Module 3 · Strings and Template Literals

CP and Interview Pack: String Patterns, the Questions and the Bug Gallery

ProReading

Amara's take-home test has one line: "Compress aaabccdddd." The expected answer is a3bc2d4: each letter followed by how many times it repeats, and a letter that stands alone left bare. She sends three working solutions. The interviewer asks one question back: "What does each one cost, and what does each one do with an empty string?" This lesson answers that kind of follow-up for six patterns, then drills the questions and the bugs.

Checking what this lesson needs for you…

What is inside CP and Interview Pack: String Patterns, the Questions and the Bug Gallery

  1. One question, three answers
  2. Pattern 1: the frequency array of 26
  3. Pattern 2: anagrams, by sorting or by counting
  4. Pattern 3: the letters seen once, in two passes
  5. Pattern 4: compression and its way back
  6. Pattern 5: two pointers from both ends
  7. Pattern 6: reversing the words of a sentence
  8. The six interview questions
  9. The contest angle