Invert a binary tree — swap every left and right child. This is the famous problem that "Homebrew's creator Max Howell couldn't solve at Google."
The simplest recursive solution:
This is a great example of how elegant recursion can be — just 3 lines of code!
inorder(root)
[1, 2, 3, 4, 6, 7, 9]
inorder(root)
[9, 7, 6, 4, 3, 2, 1]