Minimum Remove to Make Valid Parentheses (LC #1249) is currently Meta's most frequently asked question. Use a stack to track indices of unmatched opening parentheses. When you see a closing parenthesis without a match, mark it for removal. After scanning, any remaining indices in the stack are unmatched openers. Build the result string skipping marked indices. This runs in time and space. Meta asks variants: what if you can only remove from one side? What if you need to balance other bracket types?
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/arrays-strings/minimum-remove-to-make-valid-parentheses
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████████████████████████████████████████████████████████████████████████████████████████████████████