I am trying to solve the problem of whether the parentheses in the array are closed correctly or not. For example, if two pairs of parentheses are closed correctly, there are two cases: "()()" "(())". I want to first find the number of all cases of 2 pairs of parentheses, and then verify that it is closed correctly or not.
What I'm thinking is that when I try to find 2 pairs, first of all, "(", "(", ")", ")" is to make all cases first with 2 open and 2 closed parentheses. How can I get all the cases with 2 open parentheses + 2 closed parentheses? Please help me.