Shortest Call Window That Completes the Compliance Script in Order

Last updated: November 29, 2026

Quick Overview

Each utterance in a call is tagged with at most one compliance step label (or none). Given a required ordered list of steps, return the shortest contiguous range of utterances that contains the steps as a subsequence, or report that none exists.

Cresta
Coding & Algorithms
Software Engineer
Cresta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Each utterance in a call is tagged with at most one compliance step label (or none). Given a required ordered list of steps, return the shortest contiguous range of utterances that contains the steps as a subsequence, or report that none exists.

In regulated contact centers (collections, insurance, banking) Cresta's quality tooling checks that required script steps happened in order, and highlighting the tightest span helps a reviewer audit quickly. The interviewer wants an O(n times m) dynamic programming solution rather than restarting a scan from each start, and correct handling of repeated step labels.

What the Interviewer Expects
  • Recognize this as minimum window subsequence
  • Track the latest feasible start for each prefix of the steps
  • Iterate steps in reverse so one utterance satisfies at most one step
  • Return indices, not just a length
  • Analyze O(n m) time and O(m) space
Key Topics to Cover
Dynamic programming
Subsequence matching
Two pointers
Compliance checking
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you allow one utterance to satisfy several steps at once?
  • How would you allow up to one missing optional step?
  • How would you report every non-overlapping compliant window in a long call?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: labels, length nn, each a step id or None; steps, length mm, may repeat labels (for example verify twice). Output: (start, end) inclusive of the shortest window where steps appear i...

High-Level Design

Keep start[j]: among windows ending at or before the current index that contain steps[0..j] as a subsequence, the latest possible start. When the current label equals steps[j], extend the match ...


Submit Your Answer
Markdown supported

Related Questions