Larget BST in a binary tree


I think my approach will take O(n^2) time, passing all the test cases
how to solve in a better way ?

hello @dhairya16
yeah it is O(n^2) .

u can solve it in O(n) as well.