File tree Expand file tree Collapse file tree 1 file changed +0
-35
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +0
-35
lines changed Original file line number Diff line number Diff line change 11package com .fishercoder .solutions ;
22
3- import java .util .Stack ;
4-
5- /**
6- * 1249. Minimum Remove to Make Valid Parentheses
7- *
8- * Given a string s of '(' , ')' and lowercase English characters.
9- * Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions )
10- * so that the resulting parentheses string is valid and return any valid string.
11- * Formally, a parentheses string is valid if and only if:
12- * It is the empty string, contains only lowercase characters, or
13- * It can be written as AB (A concatenated with B), where A and B are valid strings, or
14- * It can be written as (A), where A is a valid string.
15- *
16- * Example 1:
17- * Input: s = "lee(t(c)o)de)"
18- * Output: "lee(t(c)o)de"
19- * Explanation: "lee(t(co)de)" , "lee(t(c)ode)" would also be accepted.
20- *
21- * Example 2:
22- * Input: s = "a)b(c)d"
23- * Output: "ab(c)d"
24- *
25- * Example 3:
26- * Input: s = "))(("
27- * Output: ""
28- * Explanation: An empty string is also valid.
29- *
30- * Example 4:
31- * Input: s = "(a(b(c)d)"
32- * Output: "a(b(c)d)"
33- *
34- * Constraints:
35- * 1 <= s.length <= 10^5
36- * s[i] is one of '(' , ')' and lowercase English letters.
37- * */
383public class _1249 {
394 public static class Solution1 {
405 public String minRemoveToMakeValid (String s ) {
You can’t perform that action at this time.
0 commit comments