Pergunta de entrevista da empresa EPAM Systems

How to validate string with brackets so they are valid