Pergunta de entrevista da empresa Meta

In a string with some random open and close parenthesis, How to remove parenthesis to get a max balanced string

Resposta da entrevista

Sigiloso

9 de mar. de 2024

I didn't get the correct answer within time