Bloomberg Interview Question

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