News for hackers. Stuff that matters.
Re:Invert a binary tree on LeetCode by wfunction on Saturday June 13, 2015 @06:30AM (#9710557)
Considering the answer is 1 line, I doubt I would have hired him either...

    def inverse(t): return Node(inverse(t.r), t.v, inverse(t.l)) if t else t
or if you must do it in place, 3 lines...

    def invert(t):
        if t: (t.l, t.r) = (invert(t.r), t.v, invert(t.l))
        return t

There are no comments on this comment yet.