Showing wrong answer

I have implemeted the code for this question…


It is showing wrong answer for all test cases, although it is showing right output for given input.
My logic is –
After building the tree.
I have checked from root node if this is bst then update the mass value.
i have also checked in the left and right side of root,

Hey @ashishnnnnn, u need to find number of nodes in ur current subtree instead of height.

Have you considered that approach ?

YES… I was doing that mistake…
Now it got accepted i have calculated the number of nodes.

So now is it working fine? If not then please share your updated code after doing this correction.

1 Like

Yaa… It is working fine Now…

Cool, if you like my explanation do give it a like :slight_smile: