first attempt at generate strings, need filter for permutations

This commit is contained in:
Jacob Delgado 2023-07-21 16:35:53 -07:00
parent 571fd5d3d2
commit 756a6a01cc

View File

@ -1,7 +1,25 @@
def generateParenthesis(n):
def generateParenthesis(n: int) -> List[str]:
"""
:type n: int
:rtype: List[str]
"""
stack = []
pairs = ""
opening_brackets = {'('}
closing_brackets = {')'}
bracket_pairs = {')': '('}
# Create n pairs
for i in range(n):
pairs += "()"
# print(pairs)
# Create and filter permutations
for pair in permutations(pairs):
parenthesis = "".join(pair)
# print(pair)
# print(parenthesis)
if parenthesis in bracket_pairs.keys():
if not stack or stack[-1] != bracket_pairs[parenthesis]:
print('bad')
generateParenthesis(3)