Longest BST in a Binary Tree


My code is not passing all test cases although giving correct output. Kindly correct my code highlighting my mistakes.

hi… what u are doing wrong is when u found that using this node the binary tree is a BST u have to update ur ans with total nodes present in that subtree and not with height…

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.