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
Left subtree < node < right subtree, everywhere
The highlighted line runs next. The pill shows the live values in the running call.
Work done so far, and how the three solutions compare
Left subtree < node < right subtree, everywhere
Keyboard: ← → step, Space play or pause. Enter the tree in level order with null for missing children, as LeetCode does (1 to 13 nodes, 5 levels, values −9999 to 9999 to keep the range labels readable).