Genrate parenthesis

i think the code is correct still its giving wrong answer…may be order of printing is different…but how to correct that