Given a string containing only '(', ')', and '*', find all unique valid combinations of parentheses where every open parenthesis can be matched with a corresponding close parenthesis or a '*'. The result should be sorted in lexicographic order.
Explanation: For a single pair of parentheses, there is only one valid combination.
Explanation: For two pairs of parentheses, there are two valid combinations with 1 pair open and the other two closed.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak