Merge Overlapping PII Detections Before Storing a Transcript
Last updated: November 29, 2026
Quick Overview
Several PII detectors (card numbers, addresses, generic numbers) return character spans over the same transcript, often overlapping. Merge the spans, label each merged span with its highest-priority type, and return the redacted text.
Cresta
November 29, 20260
0
0 solved
Several PII detectors (card numbers, addresses, generic numbers) return character spans over the same transcript, often overlapping. Merge the spans, label each merged span with its highest-priority type, and return the redacted text.
Contact center transcripts carry card numbers and personal data, and Cresta must redact them for PCI and privacy compliance before data is stored or used for training. The question checks interval merging with a priority rule and careful string reconstruction without off-by-one leaks of sensitive characters.
What the Interviewer Expects
- Sort spans and merge overlaps in one pass
- Pick the strongest label for a merged span by a priority map
- Clamp spans to text bounds and drop empty ones
- Rebuild the string in one pass rather than repeated slicing
- Explain why under-redaction is worse than over-redaction
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
- Should touching but non-overlapping spans merge? What would you choose for compliance?
- How would you redact the matching audio segments using word timestamps?
- How would you redact a card number that ASR split across two utterances?
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: text, list of (start, end, label) half-open spans, and a priority list such as [CARD, ADDRESS, NUMBER]. Overlapping spans merge into one, labeled with the highest-priority label seen. Outpu...
High-Level Design
Clean spans (clamp to text, drop empty), sort by start, sweep: if a span starts before the current merged span ends, extend the end and maybe upgrade the label; otherwise start a new merged span. Then...