1 test case got failed. For which test case it is producing wrong o/p?

hello @mb129162
u can merge subtree only when they are bst .
otherwise u have to simply return maximum of left and right subtree.

i’m not merging when they are not bst. i’ making count=0…please tell what test cases are not passing?

@mb129162 I’ve manually checked and your code is generating correct output(so its a backend issue!)
but unfortunately your code is incorrect as it checks only immediate children!
see this test case:
7
5 4 3 7 6 1 8
3 4 7 5 1 6 8


answer is 3 but your output is 7.

I have made some changes in the code and now it has passed all the test cases. Thanks : ) https://ide.codingblocks.com/s/287322

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.