Replace With Sum of Greater Nodes

In the above Link Sample Test Case Output is Coming but Solution not Accepted.

In the above Link, Both Pre-Order & In-Order are Giving Same Output.

Q1. Why Link 1 Code isn’t Accepted?

Q2. Why Link 2 Code Showing Same Output for Pre & In Order Traversals?

this is because which adding nos sum may cross range of int so instead of int use long long

asn 2
here in line no 40 you have not update root that is why it is showing wrong ans

1 Like

Thanks :slight_smile:

1 Like

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.