The problem asks you to mirror a binary tree, effectively swapping the left and right children of each node. This tests your understanding of tree traversals and recursion, crucial for many tree-based algorithms.
Given the root of a binary tree, modify the tree in-place such that the left and right subtrees of every node are swapped. Return the root of the modified tree, which should now be the mirror image of the original tree.
The brute force approach would be like manually redrawing the entire tree on a new sheet of paper, but mirroring the connections as you go. For each node, you'd create a new node in the mirrored position and connect it to the mirrored children. This creates a completely new tree.
Work through this problem with AI coaching and get real-time feedback
Practice This Problem