LINE interview question

Leet code medium Generate Parentheses.