11. Symmetric Tree
easyAsked at AsanaDetermine if a binary tree is a mirror of itself. Asana asks this to test whether you can pair two pointers across a tree — the same pattern used in their snapshot-diff symmetry checks.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Asana loops.
- Glassdoor (2026-Q1)— Asana tree warmup.
Problem
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Follow up: Could you solve it both recursively and iteratively?
Constraints
The number of nodes in the tree is in the range [1, 1000].-100 <= Node.val <= 100
Examples
Example 1
root = [1,2,2,3,4,4,3]trueExample 2
root = [1,2,2,null,3,null,3]falseApproaches
1. Inorder serialize + palindrome check
Inorder traverse, build value list, check palindrome.
- Time
- O(n)
- Space
- O(n)
function isSymmetric(root) {
const a = [];
const dfs = (n) => { if (!n) return a.push(null); dfs(n.left); a.push(n.val); dfs(n.right); };
dfs(root);
for (let i = 0, j = a.length-1; i < j; i++, j--) if (a[i] !== a[j]) return false;
return true;
}Tradeoff: Works but O(n) extra space and easy to get wrong with nulls.
2. Paired recursion
Recurse with (left, right). Mirror means left.left mirrors right.right and left.right mirrors right.left.
- Time
- O(n)
- Space
- O(h)
function isSymmetric(root) {
const 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: O(h) stack, no extra storage. The crossed-recursion (left.left vs right.right, left.right vs right.left) is the trick.
Asana-specific tips
Asana cares about the 'crossed' recursion pattern — they grade on whether you immediately see (left.left, right.right) and (left.right, right.left) as the mirror invariant. Drawing two trees side-by-side on the whiteboard before coding earns interviewer trust.
Common mistakes
- Calling mirror(a.left, b.left) — that's same-tree comparison, not mirror.
- Forgetting the root === null case.
- Returning early on (a.val === b.val) without recursing into children.
Follow-up questions
An interviewer at Asana may pivot to one of these next:
- Iterative version using a queue of pairs.
- Count the size of the largest symmetric subtree.
- Mirror a binary tree (LC 226).
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why is left.left compared to right.right?
Mirroring means flipping. The leftmost node on the left subtree corresponds to the rightmost node on the right subtree — that's left.left mirroring right.right.
Does this work iteratively?
Yes — use a queue (or stack) of pairs. Push (root.left, root.right) and BFS, pushing children in the mirrored order each time.
Practice these live with InterviewChamp.AI
Drill Symmetric Tree and other Asana interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →