Solution to Valid Parentheses

Classic stack problem