[Daily OJ——572. A subtree of another tree]

1. Topic: 572. Subtree of another tree

Insert image description here

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 of subRoot. This process Judge it through the issame function interface, and then call the interface issame function interface to judge the initial value of root 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 tree root are equal to the structure and value of subRoot.

2.2. Code implementation

Insert image description here

2.3.Submission through display

Insert image description here

Guess you like

Origin blog.csdn.net/qq_73900397/article/details/134757587