Practice Minimum Remove to Make Valid Parentheses
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Remove as few parentheses as possible from s, preserving all lowercase letters and the order of retained characters. Return any resulting string with balanced parentheses: each closing parenthesis matches an earlier opening one and none remain unmatched. Empty strings and strings containing only letters are valid.
Source: Minimum Remove to Make Valid Parentheses on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "lee(t(c)o)de)"
"lee(t(c)o)de"
# Example 2
s = "a)b(c)d"
"ab(c)d"
# Example 3
s = "))(("""
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Remove to Make Valid Parentheses.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.