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

二叉搜索树与双向链表

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]

全部评论

相关推荐

MinJerous:虽然我一直说 计算机不怎么卡学历 但是至少得一本
点赞 评论 收藏
分享
06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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