Hard · Graphs

Remove Invalid Parentheses

Given a string s of parentheses and lowercase letters, return every distinct valid string that can be made by deleting the minimum number of parentheses from s, in any order.

Examples

Example 1

{
  "s": "()())()"
}

Output: ["(())()", "()()()"]

Example 2

{
  "s": "(a)())()"
}

Output: ["(a())()", "(a)()()"]

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Graphs problems