← 返回 salesforce 的题目列表Remove Invalid Parentheses (Extended: three bracket types)
类型:online_judge
Problem: Remove Invalid Brackets (Extended: three bracket types)
Given a string s that contains three types of brackets (), [], {} (and possibly other non-bracket characters), delete the minimum number of bracket characters so that the remaining string has valid, properly matched brackets.
Return all possible resulting strings that are valid with the minimum number of deletions. The output must not contain duplicates; order does not matter.
Definition of a valid bracket string
Scanning left to right:
A closing bracket must match the most recent unmatched opening bracket of the same type.
At the end, no unmatched opening brackets remain.
Different bracket types must be properly nested (stack discipline), e.g., ([{}]) is valid while ([)] is invalid.
I/O
Input: one line string s
Output: multiple lines (or a list) representing all distinct valid strings after minimum deletions.
Constraints (suggested)
1 <= len(s) <= 30
s consists of bracket characters and optionally other characters.
Examples
Input: "([)]" -> Output: ["()", "[]"]
Input: "{[]}" -> Output: ["{[]}"]
Example
Input
([)]
Output
()\n[]