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.

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Generate all Parentheses II on Interview Code Editor
Sign Up
to access hints and editorial solutions for Generate all Parentheses II
5407 successful submissions.
Asked In:
  • Facebook
  • Microsoft
Click here to start solving coding interview questions