题解 | #二叉搜索树与双向链表#

二叉搜索树与双向链表

http://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5

# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

#
# 
# @param pRootOfTree TreeNode类 
# @return TreeNode类
#
class Solution:
    def mid_DFS(self , pRootOfTree):
        global output
        if not pRootOfTree:
            return
        self.mid_DFS(pRootOfTree.left)
        output.right=pRootOfTree
        pRootOfTree.left=output
        output=pRootOfTree
        self.mid_DFS(pRootOfTree.right)

    
    def Convert(self , pRootOfTree ):
        # write code here
        if not pRootOfTree:
            return
        global output
        output=TreeNode(None)
        self.mid_DFS(pRootOfTree)
        while output.left.val!=None:
            output=output.left
        output.left=None
        return output
全部评论
你好,我想请教一下,31-33行代码作用是什么呐?
点赞 回复 分享
发布于 2022-01-13 14:11

相关推荐

2025-12-22 16:31
已编辑
桂林电子科技大学 Python
很奥的前端仔:如果你接了offer 临时又说不去 hr确实要多做一些工作。 当然如果是接offer之前当我没说
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务