題庫
00:00

17. Generate Parentheses

中等回溯法AmazonGoogleMicrosoft

Given n pairs of parentheses, generate all combinations of well-formed parentheses.

範例 1:

輸入: n = 3
輸出: ["((()))","(()())","(())()","()(())","()()()"]

範例 2:

輸入: n = 1
輸出: ["()"]

限制條件:

  • 1 <= n <= 8
核心程式碼模式
● 已自動儲存第 1 行,第 1 欄