DotPe interview question

Valid parenthesis and generate parenthesis