LARGEST BST IN A BINARY TREE

I’d done this question , can you please check whether it is correct way of doing it or any other approach is better than this?

hello @CODER_JATIN

logic is correct but its time complexity is O(N^2)

try to solve it in O(n).

hint -> use results of child node to get the result of parent node.

refer this->link

okay and bhaiya ye jo do values swapped hai recover binary tree, iski approach kya hogi?

1 Like

inorder traversal ki direction se socho ki uska order kaise change hoga

1 Like

okay bhaiya , doing . . . . .

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.