Re: [Check whether a binary tree is contained in another binary tree](child tree structure should be considered)

  • 0

    Every binary tree has a unique serialization, hence all we need to do is serialize the two tree and use Rabin karp or some other string matching algorithm to check if T2 is a subtree of T1.

    Hence it's linear time!!!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.