Remove invalid character to make string a valid parenthesis. return all possible result string with least removal operations.
这个题的难点在于,看不出来是要用BFS.
一般看到least会想到用DP.
Solution II: BFS. (divide and conquer by cutting index) -> 一刀就是一个cost!
for any possible remove index in str,
[0, i - 1] [i + 1, end]
if we found a match, then this is minimum removal.
Solution I: DFS