摘要:
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?思路:BST就是对应的InOrder,1) 那么只需要InOrder,维持一个当前的Val,然后看下一个是不是比当前的大,如果不大,则记录位置,直到找到2个位置fi 阅读全文