#C10738. Check Symmetric Binary Tree
Check Symmetric Binary Tree
Check Symmetric Binary Tree
Given a binary tree, determine whether it is a mirror of itself (i.e., symmetric around its center). The tree is provided in level order traversal, where null
represents a missing node. A binary tree is symmetric if its left subtree is a mirror reflection of its right subtree. Formally, the mirror condition can be defined as:
Output true
if the tree is symmetric and false
otherwise.
inputFormat
A single line of input representing the level order traversal of a binary tree. The node values are separated by spaces. Each node is an integer or the string null
to denote missing nodes. For example: 1 2 2 3 4 4 3
represents a complete binary tree.
outputFormat
A single line output: true
if the binary tree is symmetric, and false
otherwise.## sample
1 2 2 3 4 4 3
true