99. Recover Binary Search Tree — two swapped nodes, O(h) Morris optional; here O(n) inorder.
Use the tabs to read the prompt, implementation, and tests separately. Syntax uses Shiki; tests can be executed on the server with node --test.
Same file as in the repo · ~20s timeout
From file header (JSDoc)
99. Recover Binary Search Tree — two swapped nodes, O(h) Morris optional; here O(n) inorder.
@param {import('../../lib/tree-node.js').TreeNode | null} root
@returns {void}