Tap here to switch tabs
Problem
Submissions

Problem: Remove Outermost Parentheses

med
30 min
Try to solve the Remove Outermost Parentheses problem.

Statement

Given a string s consisting only of parentheses, where s is a valid parentheses string, split s into a concatenation of one or more primitive valid parentheses substrings. For each primitive substring, remove its outermost pair of parentheses, then concatenate the results in the original order. Return the resulting string.

Note: A primitive valid parentheses string is a nonempty valid parentheses string that cannot be written as the concatenation of two nonempty valid parentheses strings.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s[i] is either '(' or ')'

  • s is a valid parentheses string

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Remove Outermost Parentheses

med
30 min
Try to solve the Remove Outermost Parentheses problem.

Statement

Given a string s consisting only of parentheses, where s is a valid parentheses string, split s into a concatenation of one or more primitive valid parentheses substrings. For each primitive substring, remove its outermost pair of parentheses, then concatenate the results in the original order. Return the resulting string.

Note: A primitive valid parentheses string is a nonempty valid parentheses string that cannot be written as the concatenation of two nonempty valid parentheses strings.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s[i] is either '(' or ')'

  • s is a valid parentheses string