According to the sorted order, this should be the correct output

According to the sorted order, this should be the correct output.


Or I should print in reverse order.

hello @cbcao263

image

interchnage the position of these two if and it will give the required output

Bro aapne kaise socha to swap
Like we want open, close
So Isse pehle close ton nhi ayega but open aajayega
but uske baad fir close aajayega nd starting waala aajayega

agar koi open bracket already add kar diya hai output string mein , to lexicographically smaller output dene ke liye hame usko pehle band karna chaiye right?

isiliye pehle wo if lagayenge jo closing bracket add karta ho

1 Like

ohkayyy bro
thnx for this one.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.