Given the root of a binary tree, invert the tree, and return its root.
[0, 100].-100 ≤ Node.val ≤ 100Recursively swap left and right children for every node.
Inverting a tree means mirroring it, as if you held it up to a mirror placed beside it. Everything that was on the left ends up on the right, at every level, not just at the top.
Time O(n)Space O(w)
The full walkthrough and code are part of Premium