Pergunta de entrevista da empresa Huawei Technologies

Given a string of parentheses determine if it is valid.