Invert Binary Tree, three ways

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Cost

Work done so far, and how the three solutions compare

The tree

Redrawn after every swap

Keyboard: ← → step, Space play or pause. Enter the tree in level order with null for missing children, as LeetCode does (up to 15 nodes, 5 levels, values −100 to 100). Values never change; only left and right pointers are swapped, which is why nodes move when the tree is redrawn.