[2nd verseion]4th LeetCode:22. Generate Parentheses
Solution2
In the last time, solution 1 solved “Generate Parentheses”, but it exceeded the time limit.
Now let’s try another method:
Adding pairs of parentheses “()” once a time.
This will make sure the is no un-paired parenthesis.
The execution time is now reduced but it still exceeds the limit.
So I think I should avoid using recursive, which may reduce the time complexity.
Also, suggested by PercyJiang’s try I used list(set(XXX)) to reduce the time complexity of excluding repeated sequences of parentheses.