Microsoft interview question

Valid parentheses & long island graph