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

Open every published interview problem, solution, scene, and memory room free, with no account.

More Graphs problems