Here's how to think about it: you need to find which specific parentheses are unmatched, then build a string without them.
Use a stack to track indices of open parentheses. Scan left to right. When you see (, push its index. When you see ), pop from the stack if possible. If the stack is empty, that ) is unmatched.
After the scan, anything left on the stack is an unmatched (. Collect all unmatched indices into a set, then rebuild the string skipping those positions.