Minimum Remove to Make Valid Parentheses (LC #1249) is currently Meta's most frequently asked question with a frequency score. Use a stack to track indices of unmatched opening parentheses. When you see a closing parenthesis, if the stack has an unmatched opener, pop it. Otherwise mark this closer for removal. After scanning, indices remaining in the stack are unmatched openers. Build the result skipping all marked indices. This runs in time and space. Meta asks variants about removing from only one side.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/stacks-queues/minimum-remove-to-make-valid-parentheses
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████████████████████████