FastPrepSymmetric Tree

Symmetric Tree

Bloomberg LP logoBloomberg LP● EasyNEW GRADONSITE INTERVIEW
Learn

Problem statement

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.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public boolean isSymmetric(TreeNode root) {
  // Write your code here.
}
root[1,2,2,3,4,4,3]
expectedtrue
Checking account…