DP solution to generateParenthesis