this is the link to my code.
Only test case 0 is not passing
@lakshya9410
hello lakshay,
for input
9
50 30 5 20 60 45 70 65 80
5 30 20 50 45 60 65 70 80
output should be 5
@lakshya9410
the question is to find largest subtree that is bst.
but u are finding largest bst from bt without considering subtree constraint.
one simple approach for this problem will be to go to each node and find whether that subtree is bst or not. and then return maximum size among all valid bst
Got it
Thanks man!
I have made slight changes in my code and it gets accepted.
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.