Recursion (My Solution)
1 | class Solution { |
Remarks:
- TC $O(n!\times n)$
- Add new
()
to each gaps; will have duplication, useSet
to remove.
Traceback
1 | class Solution { |
Remarks:
- TC $O(\cfrac{4^n}{\sqrt{n}})$
- From left to right, first add
(
, then add)
(
->((
->(()
->(())
->(
->()()