Code
The highlighted line runs next. The pill shows the live values in the running call.
Cost
Work done so far, and how the five solutions compare
The BST
Nodes are drawn left to right in sorted order
The highlighted line runs next. The pill shows the live values in the running call.
Work done so far, and how the five solutions compare
Nodes are drawn left to right in sorted order
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, unique values 0 to 10000; the tree must be a valid BST). k is 1-indexed.