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