Comment by hinkley

8 years ago

That’s reversing a binary tree.

Inverting == Reversing [1]

[1] https://leetcode.com/problems/invert-binary-tree/description...

  •     This problem was inspired by this original tweet by Max Howell
    

    There are many definitions of invert. This is relying on one definition that is jargon, and not widely agreed upon jargon at that.

    For a two or more dimensional “object”. Invert means to reorient the top and the bottom, while reverse swaps the left and the right.

    The two only might mean the same thing with one dimensional data structures. For instance inverting a line of text might (ambiguously) mean reversing it. Or drawing it upside down. Or upside down and backward. But at least you would expect a clarification.

  • That was fun, thanks! I remember reading that tweet a while ago, and "inverting a binary tree" sounded very complicated, but it's really just one line of code.