Domanda di colloquio di Bloomberg

Implement an algorithm that checks if a sequence of brackets is valid.