Daily OJ - 572. Subtree of another tree
1. Topic: 572. Subtree of another tree
2.Solution
2.1. Algorithm explanation
uses depth-first traversal to determine whether the value of each node of the binary tree
root
is equal to the value of each node ofsubRoot
. This process Judge it through theissame
function interface, and then call the interfaceissame
function interface to judge the initial value ofroot
and then call the main interface. The interface function is used to recursively determine whether the structure and value of the subtree of the binary treeroot
are equal to the structure and value ofsubRoot
.