On submitting its giving wrong answer for each test case

hello @J20APPPP0006
a) you need to build a normal bst .(u r building balanced bst).
b) your code will fail for following
image
because u are replacing node data with sum of right subtree.
but here consider (30) . nodes 50 ,70,60,80 are also greater than 30 so u need to include that as well in ur answer.

this is the correct approach.
image

i have included that too…in my code there are three functions…you can run this test case too…same answer is coming as given i n sample input

check ur buildbst,that codde is for balanaced bst , u need to build normal bst.

@J20APPPP0006 I hope your doubt is clear with Aman’s explanation, please let me know if you still have some queries.

are you saying to build bst taking first value as node and then start fixing nodes?..but in that case the sample input given will violate. Can you just explain me what do you mean by saying normal bst?

ok leave it , they are building balanced tree only.
the issue is with approach only.
make a global array sum=0 , do reverse inorder traversal and replace current node with sum and update sum.
check my above reply for help.

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.