22.Generate-Parentheses

22. Generate Parentheses

题目地址

https://leetcode.com/problems/generate-parentheses/

题目描述

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

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

[
  "((()))",
  "(()())",
  "(())()",
  "()(())",
  "()()()"
]

代码

Approach 1: Brute Force

Approach #2 Backtracking

Approach #3 Closure Number

Last updated

Was this helpful?