Generate all Parentheses II

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses of length 2*n.

For example, given n = 3, a solution set is:

"((()))", "(()())", "(())()", "()(())", "()()()"

Make sure the returned list of strings are sorted.

Interview Code Editor
  • Solution Approach
  • Complete Solution
3514 successful submissions.
Asked In:
  • Facebook
  • Microsoft
Click here to jump start your coding interview preparation