Skip to main content

11. Symmetric Tree

easyAsked at Plaid

Check whether a binary tree is a mirror of itself. Plaid asks this to test mirrored-recursion fluency before harder graph-symmetry problems.

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Plaid loops.

  • Glassdoor (2025)Plaid SWE I screen warm-up.
  • LeetCode Discuss (2026)Reported as Plaid OA.

Problem

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

Constraints

  • The number of nodes in the tree is in the range [1, 1000].
  • -100 <= Node.val <= 100

Examples

Example 1

Input
root = [1,2,2,3,4,4,3]
Output
true

Example 2

Input
root = [1,2,2,null,3,null,3]
Output
false

Approaches

1. Inorder traversal palindrome check

Collect inorder values and check if the list is a palindrome.

Time
O(n)
Space
O(n)
// Doesn't work — different trees can share inorder lists.
// Mention only as a tempting wrong answer.

Tradeoff: Not actually correct. Tree shape matters; inorder loses structure.

2. Mirrored co-recursive walk

Define a helper that compares left subtree against right subtree as mirrors. Recurse: left.left vs right.right, and left.right vs right.left.

Time
O(n)
Space
O(h)
function isSymmetric(root) {
  function mirror(a, b) {
    if (!a && !b) return true;
    if (!a || !b) return false;
    if (a.val !== b.val) return false;
    return mirror(a.left, b.right) && mirror(a.right, b.left);
  }
  return !root || mirror(root.left, root.right);
}

Tradeoff: Two-argument helper makes the mirror obvious. The cross-recursion (a.left vs b.right) is the only twist.

Plaid-specific tips

Plaid grades this on whether the cross-recursion comes naturally. The trap is recursing into a.left vs b.left (same-tree pattern) — that checks equality, not symmetry. Bonus signal: explain the mirror invariant out loud before coding.

Common mistakes

  • Recursing same-side (a.left vs b.left) instead of cross-side.
  • Forgetting the both-null base case.
  • Trying to use inorder traversal — different shapes can match.

Follow-up questions

An interviewer at Plaid may pivot to one of these next:

  • Convert to iterative using a queue of pairs.
  • Mirror a tree in place (LC 226).
  • Check if a tree is a 'near-mirror' allowing one mismatched node.

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why doesn't inorder work?

Trees with different shapes can produce identical inorder lists if null positions differ. Structure matters for symmetry.

Is the iterative version easier to debug?

Often yes — push (left.left, right.right) and (left.right, right.left) as pairs. It's the same algorithm; pick whichever you find clearer.

Practice these live with InterviewChamp.AI

Drill Symmetric Tree and other Plaid interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →