public class Solution {
public void connect(TreeLinkNode root) {
if (root == null) return;
helper(root.left, root.right);
}
public static void helper(TreeLinkNode l, TreeLinkNode r) {
if (l == null) return;
l.next = r;
helper(l.left, l.right);
helper(l.right, r.left);
helper(r.left, r.right);
}
}
Leetcode 116. Populating Next Right Pointers in Each Node
最新推荐文章于 2023-11-09 13:02:00 发布