InfinityLabs interview question

Verify parentheses validity, pseudocode is enough