Find minimum covering substring
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Onsite
Quick Answer: This question evaluates algorithmic problem-solving skills in string processing, focusing on managing character multiplicities and correctness when identifying constrained substrings.
Constraints
- Characters are case-sensitive
Examples
Input: ('ADOBECODEBANC', 'ABC')
Expected Output: 'BANC'
Explanation: Classic minimum window.
Input: ('a', 'aa')
Expected Output: ''
Explanation: Impossible.
Input: ('aa', 'aa')
Expected Output: 'aa'
Explanation: Whole string.
Input: ('bba', 'ab')
Expected Output: 'ba'
Explanation: Left shrink after satisfying counts.
Hints
- Expand with the right pointer, then shrink while all required characters are covered.