Remove minimum invalid mixed brackets
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
Quick Answer: This Coding & Algorithms problem evaluates string-processing and bracket-matching skills, specifically understanding of stack-based parsing, handling multiple bracket types, and minimizing removals while preserving non-bracket characters.
Examples
Input: ('([{ab)',)
Expected Output: '(ab)'
Explanation: Prompt-style mixed invalid brackets.
Input: ('([)]',)
Expected Output: '()'
Explanation: Must remove a crossing pair.
Input: ('a{b[c]d}e',)
Expected Output: 'a{b[c]d}e'
Explanation: Already valid.
Input: ('}{abc',)
Expected Output: 'abc'
Explanation: Unmatched closers/openers.
Hints
- Dynamic programming can choose a maximum kept valid bracket subsequence while preserving all letters.