← LinkedIn Interview Insights

LinkedIn·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

LinkedIn software engineer interview that came down to a single tree problem, asked to solve it two ways. Pretty standard coding round but the dual-solution requirement tripped me up a bit.

Questions Asked (1)

Q1

Given the root of a binary tree, determine whether the tree is symmetric around its center. You need to provide both a recursive and an iterative solution.

Algorithms & Data Structures
Author's notes

The recursive part came naturally.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying that symmetry means the left subtree is a mirror reflection of the right subtree. Then present both recursive and iterative solutions: the recursive one compares left and right subtrees using a helper function, while the iterative one uses a queue to compare nodes level by level in pairs.

Pro tip: Mention that the iterative solution can use a queue or stack, and that the recursive solution may hit stack overflow for very deep trees, so the iterative approach is often preferred in production. Also, note that an empty tree is symmetric.

1. Clarify the problem

Define symmetry: a tree is symmetric if the left subtree is a mirror image of the right subtree. Confirm edge cases: empty tree is symmetric, single node is symmetric.

2. Recursive solution

Write a helper function isMirror(left, right) that returns true if both are null, or if both are non-null and their values are equal and isMirror(left.left, right.right) and isMirror(left.right, right.left) are true. Call isMirror(root, root) or isMirror(root.left, root.right).

3. Iterative solution

Use a queue (or stack) to store pairs of nodes to compare. Initialize with (root, root) or (root.left, root.right). While the queue is not empty, dequeue two nodes, check if both null (continue), if one null or values differ (return false), then enqueue (left.left, right.right) and (left.right, right.left).

4. Analyze complexity

State that both solutions have O(n) time complexity and O(n) space complexity (recursive call stack or queue size). Mention that the iterative solution avoids stack overflow for deep trees.

5. Test with examples

Walk through a simple symmetric tree (e.g., [1,2,2,3,4,4,3]) and an asymmetric tree (e.g., [1,2,2,null,3,null,3]) to demonstrate correctness.

Key Points to Mention

  • Definition of symmetry: left subtree is mirror of right subtree
  • Recursive helper function comparing left and right nodes
  • Iterative approach using a queue or stack for level-order comparison
  • Time and space complexity: O(n) time, O(n) space
  • Edge cases: empty tree, single node, trees with duplicate values
  • Trade-offs: recursion simplicity vs. iterative stack overflow avoidance

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.