Approach hintTry it first, then revealHide
Scan while tracking how many opening brackets are still unmatched; a closing bracket that arrives when none are open can never be matched in place and must be moved. Count such brackets.
Scan while tracking how many opening brackets are still unmatched; a closing bracket that arrives when none are open can never be matched in place and must be moved. Count such brackets.