Is subtree problem

problem: https://practice.geeksforgeeks.org/problems/check-if-subtree/1

my solution: https://ide.codingblocks.com/s/468854

hello @samardeep

you approach will fail if tree contains duplicate data.

it means this code will work if both the tree is bst?

it will work for all such tree whose all nodes will have distint values

can you please help in me optimization part https://ide.codingblocks.com/s/468888

this approach will remain O(n^2).

read the ediotrial given in the problem for O(N) approach

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.