mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Add approach description
This commit is contained in:
parent
1350b46474
commit
1d974b2ea1
1 changed files with 10 additions and 0 deletions
|
@ -15,6 +15,16 @@
|
|||
#
|
||||
# 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
|
||||
# @return {String[]}
|
||||
def generate_parenthesis(n)
|
||||
|
|
Loading…
Reference in a new issue