Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty straight forward. Could you devise a constant space solution? 示例 1: 输入:root = [1,3,null,null,2] 输出:[3,1,null,null,2] 解释:3 不能是 1 左孩子,因为 3 > 1 。交换 1 和 3 使二叉搜索树有效。 示例 2: 输入:root = [3,1,4,null,null,2] 输出:[2,1,4,null,null,3] 解释:2 不能在 3 的右子树中,因
| 105 | /// 输出:[2,1,4,null,null,3] |
| 106 | /// 解释:2 不能在 3 的右子树中,因为 2 < 3 。交换 2 和 3 使二叉搜索树有效。 |
| 107 | pub struct RecoverBinarySearchTree; |
| 108 | |
| 109 | /// Given two binary trees, write a function to check if they are equal or not. |
| 110 | /// Two binary trees are considered equal if they are structurally identical and |
nothing calls this directly
no outgoing calls
no test coverage detected