Invert a binary tree by recursively swapping left and right child pointers.
When this program is compiled and executed, the terminal outputs:
Original In-Order: 1 2 3 4 6 7 9 Inverted In-Order: 9 7 6 4 3 2 1
Practice in our high-performance cloud container IDE with multi-file support, interactive terminal STDIN, real-time memory visualizer, and structured lessons.
Traverse a binary tree level by level using Breadth-First Search (BFS) with an ArrayDeque queue in Java.
Find two indices in an array of integers that add up to a specific target number using a single-pass HashMap in O(n) time.
Reverse strings in Java efficiently using StringBuilder and in-place char array two-pointer swapping.