LeetCode: 22. Generate Parentheses

Problem: 22. Generate Parentheses

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

Algorithm: https://www.youtube.com/watch?v=sz1qaKt0KGQ

Difficulty: Medium

Description:

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:

[
“((()))”,
“(()())”,
“(())()”,
“()(())”,
“()()()”
]

Solution: 

Language: Swift

Runtime: 24ms
Memory: 18.9MB

Copy to Clipboard