Licious may need one algorithmic service to process numeric combinations and construct valid packaging expression patterns. Implement both operations: find every unique triplet that sums to zero, and generate every valid sequence containing n pairs of parentheses.
Implement solve_3sum_and_parentheses(nums, n):
nums is a list of integers. Return all unique triplets [a, b, c] such that a + b + c == 0. Each triplet must be sorted in nondecreasing order, and the collection must not contain duplicates.n is a nonnegative integer. Return all strings containing exactly n opening and n closing parentheses that are balanced and properly nested.Return a dictionary with keys triplets and parentheses. The triplets should be produced in lexicographic order, and parentheses should be generated with opening parentheses attempted before closing parentheses.
def solve_3sum_and_parentheses(nums, n):