A parentheses string of length 2n consists of n opening brackets ( and n closing brackets ).
A valid parentheses string is defined like this:
A string you can turn into the empty string by repeatedly erasing an adjacent () pair.
For example, (()) is valid. Erase the pair at positions 2 and 3 to get (), then erase that pair to get the empty string. )()( is not valid. Erasing the pair at positions 2 and 3 leaves )(, and nothing more can be erased.
Collect every valid parentheses string with n opening and n closing brackets, sort them in lexicographic order, and find the k-th one. In this comparison ( comes before ).
For n=3 the valid parentheses strings in lexicographic order are:
((()))
(()())
(())()
()(())
()()()