This question evaluates understanding of binary search trees, in-order traversal invariants, and in-place detection and correction of two swapped keys without altering tree structure.

You are given the root of a binary search tree in which exactly two nodes’ keys were accidentally swapped. Restore the tree so that its in-order traversal is strictly non-decreasing, without changing the tree’s structure. Aim for O(n) time and O(