Plz correct this

hello @rakesh800650
what issue u r facing?

I am not getting correct ans for when query 2 comes

check now->

now u need to print output in sorted order for that , store all ur output data in some vector.
sort the vector and then print

one test case is showing wrong ans

after storing into vector and sort it

probably the issue is with create tree function, u can use map only when data is distinct but in problem it is not mentioned that all elements are distinct.
check this->

check ur updated code here->

they are printing 0 , for empty cases

Sir I am not getting why it is printing 0
Plz correct it

it is just output format , there is no logic behind it

i have already shared ur corrected code.

But sir correct ed code is showing wrong ans for 1 testcase

it is working fine on my side->

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.