This theory is part of Premium
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricingFind and fix the two swapped nodes of a broken search tree with constant extra memory.
What this asks
Find and swap the two mistaken nodes of a BST without spending extra memory.
An in-order walk of a healthy BST ascends; track the first pair that breaks the order and the last node involved, then swap those values.
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricing