Pregunta de entrevista de BAE Systems

Write an algorithm to ensure parentheses are matched in a string.