Akshay Kumar

Results 25 comments of Akshay Kumar

@ykdojo When we get the minimum number of operations to solve this problem then we can easily create the valid parenthesis using backtracking. From the above example, we know that...

I can say this is two step process/solution: > Count the operations we need to add to make it valid. > Using that count, create the valid parenthesis and return...

Exactly, we can say the second one is `follow up` `output a list (or a set) of end-state valid parenthesis strings`.

Brute Force Solution: Step 1 counts a minimum number of operations to make parenthesis valid. `class Solution { public int minimumOperations(String str){ if(str.length() ==0){ return 0; } int addOperations =...

Step -2 Generate Valid parenthesis with minimum count and return the result class Solution { public List generateValidParenthesis(int num){ List res = new ArrayList(); backtrack(res, num, 0, 0, ""); return...

@ykdojo Please check this solution. This is a brute force approach, we can optimize this solution, and let me know your thoughts on it. Thanks.

@ykdojo sure, please check on this and we will come up with an optimized solution.