https://ide.codingblocks.com/s/218470 first test case is not passing
Largest bst in a bt
hello @shampblocks,
you need to find a maximum size subtree that is bst.
the approach ur are trying is top down i.e from head . which may or maynot count a subtree,
one simpe approach will to visit each node and check whether subtree from that node is bst or not.
but why this is not passing??
@shampblocks
your code does not count all nodes of a subtree .
for example->
here ur code will cosider node 2 ,5 ,7 which is wrong because if u are considering subtree of node 2 then u need to consider every node that comes under it
is there any other approach other then bruteforce??
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.