Answer: MongoDB Associate Developer Interview Question 2022 November | Trees | on-campus
Answer · Posted Jun 2026
Solution: Recursive Mirror Check Approach A tree is symmetric if its left and right subtrees are mirror images of each other. Two trees are mirrors if: their root values are equal, the left subtree of one is a mirror of the right subtree of the other. Implement a helper function isMirror(left, right) that checks this recursively. Base cases: both null means symmetric (return true), only one null means asymmetric (return false). For non-null nodes: values must match AND isMirror(left.left, right.right) ...
The full answer & interview discussion are available to premium members.
Log in Create a free account