101. Symmetric Tree

Description

Given a binary tree, check whether it is a mirror of itself (i.e, symmetric around its center).

Constraints

Approach

Examples

Input: [1, 2, 2, 3, 4, 4, 3]

Output: true

Solutions

// Definition for a binary tree node.
public class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    
    TreeNode() {}
    
    TreeNode(int val) { this.val = val; }
    
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}

Follow up

Last updated

Was this helpful?