Loading...
Loading...
Loading...
A tree is symmetric if its left side is the mirror image of its right side, in shape and in values. Print YES or NO. An empty tree is symmetric.
Example 1
Input
1 2 2 3 4 4 3
Output
YES
Symmetric.
Example 2
Input
1 2 2 null 3 null 3
Output
NO
The 3 values both sit on the right.
Try the problem first. Open one hint at a time.
Compare the left side of one half with the right side of the other.
Two missing nodes match. One missing node does not.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor