Please help, code not working properly

https://ide.codingblocks.com/s/393924 my solution

Hey @anshufirefox
it will not work for multiple tc
So do it like this

reason of not working for many tc?

because say for current testcase
sum is 10
now for next testcase it will keep that 10 and solve for current so thats why

The function with the same name that you’ve coded below my code, what does it do? And how is it working?

I kept your code same just changed the function name in it

And from the original function
i just initialised sum to 0
then called your logic function
and then returned sum

Got it, thanks a lot

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.

Btw since the BST1 function has an integer return type, why haven’t you stored it? Will only calling the function and not storing the return value work?

yes because its global u can also save and return

Thanks understood it

1 Like