My-LeetCode-Solvings

C# Code Challenges Solved on LeetCode


Project maintained by F4NT0 Hosted on GitHub Pages — Theme by mattgraham

1249. Minimum Remove to Make Valid Parentheses

Level: Medium

Language: C#

Topic: Stack

Unit Tests: 1249 - Testing Results


Given a string s of '(' , ')' and lowercase English characters.

Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string.

Formally, a parentheses string is valid if and only if:

Example 1:

Example 2:

Example 3:

Constraints: