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

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Graphs problems