原题:
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
- You may only use constant extra space.
For example,
Given the following binary tree,
这个题是学渣遇到最无奈的一个题。。。。竟然用了1的代码没改就过了。。。。尼玛,莫非是做1的时候想的太多?
Populating Next Right Pointers in Each Node
我看了一下1和2的区别就是2不是完全二叉树。。。。然后其实就是需要判断一下左子树是否为空,若为空,不入栈