Add approach description

This commit is contained in:
Vitor Oliveira 2021-04-01 09:58:04 -07:00
parent 1350b46474
commit 1d974b2ea1

View file

@ -15,6 +15,16 @@
# #
# 1 <= n <= 8 # 1 <= n <= 8
# Approach:
#
# Let's only add '(' or ')' when we know it will remain a valid sequence.
# We can do this by keeping track of the number of opening and closing brackets
# we have placed so far.
#
# We can start an opening bracket if we still have one (of n) left to place.
# And we could start a closing bracket if it'd not exceed the number of opening
# brackets.
# @param {Integer} n # @param {Integer} n
# @return {String[]} # @return {String[]}
def generate_parenthesis(n) def generate_parenthesis(n)