Only test case 0 is not passing


this is the link to my code.

@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

1 Like

@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

1 Like

Got it :slight_smile:
Thanks man!

I have made slight changes in my code and it gets accepted.

@lakshya9410
great…

@lakshya9410
if ur doubt is resolved then pls mark it as resolved

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.