Given $n$ strings consisting only of '$($' and '$)$', how one can compute the length of the longest string that can be built by concatenating a subset of these strings in some order such that the resulting string is a balanced parenthesis?Example: If we have the strings $\{((),)(,),((\}$, one can build the string $(())()$ which has length 6.  We cannot construct a longer one from the previous set, thus the answer is 6.In general, the answer is always even, and always $\geq 0$ because we can always take the empty set.Problem source: North American Invitational Programming Contest (NAPIC) 2017, Problem A.
Finding longest balanced parentheses using $n$ smaller strings
algorithms;strings;permutations;algorithm design