Pergunta de entrevista da empresa SolarWinds

Find valid parenthesis pairs in a string with alphabets and brackets.