Idea one:
Traverse according to the conventional method, find the same root node and compare the child nodes once, if it fails, check the next node
The time complexity is O(n*m)
Idea two:
Using the tree structure serialization method, serialize the two trees in the same way, and then use kmp to judge the substring, you can get
As a result, the time complexity is O(m+n)
The feasibility of this question is: the serialization and deserialization of number structures are in one-to-one correspondence