Shortest Transcript Window Containing Every Requested Siri Keyword
Last updated: November 29, 2026
Quick Overview
Given a Siri transcript as a list of tokens and a list of required keywords (which may repeat), return the start and end indices of the shortest contiguous window that contains every keyword with at least its required multiplicity, or (-1, -1) if none exists.
Apple
November 29, 20260
0
0 solved
Given a Siri transcript as a list of tokens and a list of required keywords (which may repeat), return the start and end indices of the shortest contiguous window that contains every keyword with at least its required multiplicity, or (-1, -1) if none exists.
An onsite coding round for Siri or speech teams, framed around extracting the tightest span of an utterance that satisfies an intent's slot words. The interviewer is checking a correct variable-size sliding window with a 'formed' counter, not a quadratic scan.
What the Interviewer Expects
- Track required counts with a counter and a count of satisfied keywords
- Expand the right edge, then shrink the left edge while still valid
- Respect keyword multiplicity
- Return indices and handle the no-solution case
- Explain O(n + m) time
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Keywords must appear in the given order; how does the solution change?
- Tokens arrive as a live stream; return the best window seen so far with bounded memory.
- Match case-insensitively and treat stems such as 'play' and 'playing' as the same keyword.
- What if you want the shortest window by audio duration instead of token count?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: tokens (list of strings, length n) and keywords (list of strings, length m). Output: (start, end) inclusive for the shortest window covering all keywords with multiplicity; ties go to the...
High-Level Design
Count required occurrences in need. Keep have counts for the current window and formed, the number of distinct keywords whose count requirement is met. Move right across tokens; when a token's...