Class Solution

java.lang.Object
g0101_0200.s0101_symmetric_tree.Solution

public class Solution extends Object
101 - Symmetric Tree.<p>Easy</p> <p>Given the <code>root</code> of a binary tree, <em>check whether it is a mirror of itself</em> (i.e., symmetric around its center).</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/02/19/symtree1.jpg" alt="" /></p> <p><strong>Input:</strong> root = [1,2,2,3,4,4,3]</p> <p><strong>Output:</strong> true</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/02/19/symtree2.jpg" alt="" /></p> <p><strong>Input:</strong> root = [1,2,2,null,3,null,3]</p> <p><strong>Output:</strong> false</p> <p><strong>Constraints:</strong></p> <ul> <li>The number of nodes in the tree is in the range <code>[1, 1000]</code>.</li> <li><code>-100 <= Node.val <= 100</code></li> </ul> <p><strong>Follow up:</strong> Could you solve it both recursively and iteratively?</p>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • isSymmetric

      public boolean isSymmetric(TreeNode root)