Answer: Twilio OA Question 2024 August | Trees | on-campus
Answer · Posted Jun 2026
Solution: Symmetric Tree — Recursive Mirror Check Approach A tree is symmetric if its left subtree is a mirror image of its right subtree. We define a helper function isMirror(left, right) that checks if two subtrees are mirrors: If both nodes are null: they mirror each other — return true. If only one is null (or their values differ): not a mirror — return false. Recursively check: the outer pair (left.left vs right.right) and the inner pair (left.right vs right.left) ...
The full answer & interview discussion are available to premium members.
Log in Create a free account