-
[LeetCode] Generate Parentheses알고리즘 2019. 9. 26. 02:19
문제
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
(의 최대 개수는 n개이고 )는 n이 등장한 만큼만 나와야한다
이 조건을 만족하며 완전탐색을 한다
Code
https://github.com/chi3236/algorithm/blob/master/LeetCode_GenerateParentheses.cpp
'알고리즘' 카테고리의 다른 글
[LeetCode] Remove Duplicates from Sorted Array (0) 2019.09.29 [LeetCode] Merge k Sorted Lists (0) 2019.09.28 [LeetCode] Letter Combinations of a Phone Number (0) 2019.09.21 [LeetCode] Container With Most Water (0) 2019.09.21 [LeetCode] Merge Two Sorted List (0) 2019.09.21