Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
At each step, isn't it simpler to just add the pair of parentheses by either enc...

Ivy

May 7, 2022

At each step, isn't it simpler to just add the pair of parentheses by either enclosing or appending to the previous combinations? e.g. Step 1: () Step 2: ()() (()) Step 3: ()()(), (()()) (())(), ((())) I believe the string operations would cost the same amount of time as well, so I don't think this solution compromises on any space-time efficiency.

0

0

Comments
Comments
R
Richard Yuan3 years ago

You will also have to figure out logic on how to add ()(()) as one of the combinations since you're missing it in Step 3.

On this page