Generating Parenthesis Problem

please check the code.
sir , i am stuck in this problem . How do i check for the conditions.

hello @Pramod123
in ur check function use single variable say a.
intitalise it with zero.
start iterating ur string from i=0 to i=n-1.
{ if out[i]==’(’ then a++
else a- -
if(a<0)
return false;

}
if a!=0
return false

otherwise return true

Its not working sir… not getting any output if i do if (a!=0) return false ; but when i do return true ; it give results but not what the problem need

pls share ur updated code

https://ide.codingblocks.com/s/225597 not getting correct answer…plzzzz check

issue is with part of ur code

instead of doing this simply declare ur set as set<string,greater < string> > v;

and print string from beginning to end