测试用例不全

二叉树的下一个结点

http://www.nowcoder.com/questionTerminal/9023a0c988684a53960365b889ceaf5e

牛客测试用例不全,这也能通过,建议增加测试用例

class Solution:
    def GetNext(self, pNode):
        # write code here
        if not pNode:
            return pNode
        if pNode.right:
            left = pNode.right
            while left.left:
                left = left.left
            return left
        if pNode.next:
            if pNode.next.left == pNode:
                return pNode.next
            if pNode.next.next:
                if pNode.next.next.left and pNode == pNode.next.next.left.right:
                    return pNode.next.next
        return None

全部评论

相关推荐

Twilight_m...:还是不够贴近现实,中关村那块60平房子200万怎么可能拿的下来,交个首付还差不多
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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