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
Every node: |height(left) − height(right)| ≤ 1
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
Every node: |height(left) − height(right)| ≤ 1
Keyboard: ← → step, Space play or pause. Enter the tree in level order with null for missing children, as LeetCode does (0 to 13 nodes, 5 levels, values −1000 to 1000). The small badge on a node is the value the algorithm has worked out for it so far.