DotPe Interview Question

Valid parenthesis and generate parenthesis