Z47

Remove Invalid Parentheses

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: ARRAY

Problem Statement & Objective

Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid. Return all unique results.

Function Signature (Python)

remove_invalid_parentheses(s: str) -> list[str]

Input & Output Contract

Output Rule:Alfabetik sıralı benzersiz geçerli parantez dizgileri listesi.

System Constraints

1 <= s.length <= 25
s yalnızca '(', ')' ve küçük İngilizce harfler içerir

Example Execution Walkthrough

s = '()())()' -> 1 parantez silinerek ['(())()', '()()()'] elde edilir
s = '(a)())()' -> ['(a())()', '(a)()()']
s = ')(' -> ['']

Example Test Scenarios (3)

Example 1: İki Olasılık
Input:["()())()"]
Expected Output:["(())()","()()()"]
Example 2: Harf İçeren
Input:["(a)())()"]
Expected Output:["(a())()","(a)()()"]
Example 3: Boş Diziye İndirgeme
Input:[")("]
Expected Output:[""]
Loading Python Editor...
Input Parameters
[
  "()())()"
]
Expected Output
[
  "(())()",
  "()()()"
]