Largest BST in a Binary Tree

Can you give a look in my code please?

Hi kinjal , your code is a little bit complicated … what i would suggest is that you should notice the constraints as 1000 only that means we can have a n^2 code for sure . I would say that (to not miss any case) make every node as a root and check if it has any subtree as BST or not ,isBST can checked in O(n) . So overall it will get accepted.

Sorry!!! I didn’t put my doubt in public forum to judge my code. I have put it to change or correct my code or tell me about new approach.