Loading problem…
This problem builds on valid-parentheses-iii. Complete that first, then load your solution to continue.
Given n pairs of parentheses, return every distinct well-formed string using exactly n opening and n closing parentheses. Return the strings in any order.
A well-formed string never has more closing than opening parentheses in any prefix, and ends with equal totals. For compatibility, n = 0 returns [""].
Example 1:
Example 2: