《leetCode》:Populating Next Right Pointers in Each Node II

题目

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
       /  \
      2    3
     / \    \
    4   5    7
After calling your function, the tree should look like:
         1 -> NULL
       /  \
      2 -> 3 -> NULL
     / \    \
    4-> 5 -> 7 -> NULL

思路

与上篇博文的思路一样,代码也一样,因为上篇博文的实现代码就可以满足任意结构的二叉树(不一定是完成二叉树);

这里,就不贴代码了,提供一个上篇博文的连接:
http://blog.csdn.net/u010412719/article/details/50756766

你可能感兴趣的:(LeetCode,Populating,nextRight)