cpp implementation of Generate Parenthesis