Given the root node of a binary tree, determine if the tree is symmetric with respect to its center. A binary tree is symmetric if the left subtree is a mirror reflection of the right subtree.
Example 1
Input: TreeNode(10, TreeNode(20, TreeNode(30), TreeNode(40)), TreeNode(20, TreeNode(40), TreeNode(30)))
Output: True
Explanation: The tree is symmetric.
Example 2
Input: TreeNode(5, TreeNode(8, None, TreeNode(9)), TreeNode(8, None, TreeNode(9)))
Output: False
Explanation: The tree is not symmetric because the left and right subtrees are not mirror images.
Constraints
Case 1
Input: TreeNode(1, TreeNode(2, TreeNode(3), None), TreeNode(2, None, TreeNode(3)))
Expected: True
Case 2
Input: TreeNode(7, TreeNode(6, TreeNode(5), TreeNode(4)), TreeNode(6, TreeNode(4), TreeNode(5)))
Expected: True
Case 3
Input: TreeNode(2, TreeNode(3), TreeNode(3, None, TreeNode(4)))
Expected: False