226. Invert Binary Tree
Easy
Problem:
Invert the binary tree based on the center.

https://leetcode.com/problems/invert-binary-tree/
Solution:
Pythonic way
For reference, the last "return None" can be omitted. While languages like Java or C++ would throw an error if nothing is returned, Python assigns None by default.
BFS/DFS
Previously, the recursive solution was a bottom-up approach that descends to the furthest leaf nodes and backtracks while swapping. In contrast, this solution is a top-down approach that starts from the parent node, swaps, and continues descending downward.
Last updated