Pattern Recognition Drill
Easy Advanced Trees
The Problem
Check if a binary tree is its own mirror image.
What approach would you use?
Think about it before scrolling down.
is_mirror(left, right): both null → True. One null → False. Values match AND subtrees mirror. O(n).
BFS with pairs: enqueue (left.left, right.right) and (left.right, right.left). Same O(n).
Common Trap
Don't just check if inorder traversal is a palindrome — that's necessary but not sufficient.