• 34.9%

https://leetcode.com/problems/remove-invalid-parentheses/#/description

Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.

Note: The input string may contain letters other than the parentheses ( and ).

https://discuss.leetcode.com/topic/28831/my-c-dfs-solution-16ms

My C++ DFS Solution - 16ms

https://discuss.leetcode.com/topic/34996/recommend-for-beginners-clean-c-implementation-with-detailed-explaination

[recommend for beginners]clean C++ implementation with detailed explaination

https://discuss.leetcode.com/topic/28819/c-depth-limited-dfs-3ms-eliminate-duplicates-without-hashmap

C++ Depth limited DFS 3ms. Eliminate duplicates without hashmap.

num1 and num2 stand for the number of ‘(‘ and ‘)’ to remove respectively. Duplicates arise from consecutive ‘(‘ or ‘)’. We only get rid of the first one before going a level further.

https://discuss.leetcode.com/topic/28833/short-python-bfs

Short Python BFS

Solution 1

Being lazy and using eval for checking:

Update: Meh, ok, checking it myself isn’t that much longer, and it’s three times as fast:

Solution 2

Solution 3

Just a mix of the above two.

Solution 4

Yet another way to do isvalid.

https://discuss.leetcode.com/topic/29096/python-dp-solution

Python DP Solution

We can perceive the task as minimization the number of removed parenthesis and represent the solution as recursive with parameters si - ‘Start Index’ and oc - ‘Open Count’.

DropCount = min(DropCount[si + 1][oc], DropCount[si + 1][oc + {1 if s[si] == ‘(‘ else -1}]

101ms, 40.15%, October 15, 2016

https://discuss.leetcode.com/topic/28827/share-my-java-bfs-solution

3ms, 81.22%, October 15, 2016

https://discuss.leetcode.com/topic/34875/easy-short-concise-and-fast-java-dfs-3-ms-solution