Java - dead simple, but sloooowwww!!!!


  • 0
    public void connect(TreeLinkNode node) {
        if (node == null) return;
        if (node.left != null && node.right != null)
        {
            node.left.next = node.right;
            if (node.next != null)
            {
                node.right.next = node.next.left;
            }
            connect(node.left);
            connect(node.right);
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.