Domanda di colloquio di Yandex

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.