Reported October 2019
Bloombergtree

Symmetric Tree

Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Bloomberg OA. Under 2s to a working solution.
Founder's read

Most first attempts at Symmetric Tree fail the same way: the candidate compares the left subtree to the right subtree as if they should be identical, not mirrored. Bloomberg reported this one in October 2019, and it's a clean tree problem that punishes that one slip. You get a binary tree and return true if it mirrors itself around its center. Example: [1,2,2,3,4,4,3] is true. It's short, it's familiar, and it's easy to blank on under a timer. If that happens, StealthCoder runs invisibly on the live OA and gives you the solution as a safety net.

The problem

Return true when the binary tree is a mirror of itself around its center, and false otherwise.

Function
isSymmetric(root: TreeNode) → boolean

Examples
Example 1
root = [1,2,2,3,4,4,3]
return = true
The left and right subtrees mirror each other.

Constraints
The tree contains at most 10^5 nodes.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a helper that takes two nodes at once. Call it on root.left and root.right. Two nulls return true. One null returns false. Different values return false. Otherwise recurse on (a.left, b.right) and (a.right, b.left). That crossing of the pairs is the whole mirror idea. The classic pitfall is calling it with (a.left, b.left), which checks for equal trees and fails on real mirrors. Another is forgetting the one-null case and crashing on a null dereference. Watch the constraint too: up to 10^5 nodes means a skewed tree can make recursion deep, so an iterative version with a queue or stack is the safer choice in some languages. Time is O(n), space is O(h) for recursion or O(n) for a queue. If you freeze on the cross-pairing during the live OA, StealthCoder is the hedge that hands you the working version.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Symmetric Tree cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as symmetric tree. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Bloomberg's OA.

Bloomberg reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Symmetric Tree FAQ

How hard is Symmetric Tree really?+

It's easy on paper, but the mirror logic trips people up. Once you see that you compare outer pair to outer pair and inner to inner, it's about ten lines. Most failures come from comparing left to left instead of left to right.

What's the trick to solving it?+

Write a helper that takes two nodes and checks them together. Compare their values, then recurse on (a.left, b.right) and (a.right, b.left). Handle both-null as true and one-null as false first. That crossing is the entire idea.

Should I use recursion or iteration?+

Either works. Recursion is shorter and easier to get right fast. With up to 10^5 nodes, a very skewed tree can cause deep recursion, so an iterative queue approach that pushes mirrored pairs is the safer option if your language has a shallow stack.

Is this tree pattern still asked?+

Tree traversal with paired recursion keeps showing up, and Bloomberg reported this one in October 2019. Variants like same tree, invert tree, and subtree checks use the same two-node helper idea, so it's worth knowing cold.

How do I prepare in 48 hours?+

Write this solution from scratch twice, once recursive and once iterative. Test with a single node, an empty-side tree, and the sample [1,2,2,3,4,4,3]. Then do same tree and invert tree quickly. Focus on null handling, since that's where bugs hide.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Bloomberg.

OA at Bloomberg?
Invisible during screen share
Get it