Daily OJ - 101. Symmetric Binary Tree
1.Topic: 101. Symmetric Binary Tree
2.Solution
2.1. Algorithm explanation
1. This question is to determine whether the binary tree is symmetrical. The key is that the left subtree is equal to the right subtree, and the given interface has only one parameter, so an interface must be implemented to determine whether the left and right subtrees are equal. , and then convert to whether the binary tree is symmetric.
2. If both the left and right subtrees of the binary tree are empty, it is symmetrical. If only one of the subtrees is empty, it is asymmetrical. It is also asymmetrical if the values are not equal. Then in the recursive judgment Whether the left and right subtrees are symmetrical is ultimately used to determine whether the binary tree is symmetrical.