Find Dictionary Matches for a Jammed String
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
Quick Answer: This question evaluates string-processing and pattern-matching skills, specifically run-length grouping of consecutive characters and efficient dictionary lookup, within the Coding & Algorithms domain.
Part 1: Find All Dictionary Words That Could Produce a Jammed String
Constraints
- 0 <= len(dictionary_words) <= 10^4
- 0 <= len(jammed_string) <= 10^5
- The sum of lengths of all dictionary words is at most 2 * 10^5
- All strings contain only lowercase English letters
Examples
Input: (['help', 'hello', 'shell', 'hellp'], 'hellp')
Expected Output: ['help', 'hellp']
Explanation: help can expand its single l into ll, and hellp already matches exactly.
Input: (['hello', 'halo', 'heeello'], 'hheeellllo')
Expected Output: ['hello', 'heeello']