题解 | #二叉搜索树与双向链表#
二叉搜索树与双向链表
https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5
class Solution: def Convert(self , pRootOfTree ): if not pRootOfTree: return None def inorder(root): if not root: return [] return inorder(root.left) + [root] + inorder(root.right) tmp = inorder(pRootOfTree) for i in range(len(tmp) - 1): tmp[i].right = tmp[i+1] tmp[i+1].left = tmp[i] return tmp[0]