/**
* Definition for a Node.
* struct Node {
* int val;
* struct Node *left;
* struct Node *right;
* struct Node *next;
* };
*/
struct Node* connect(struct Node* root) {
if(root==NULL){
return NULL;
}
if(root->left==NULL&&root->right==NULL){
return root;
}
root->left->next=root->right;
if(root->next!=NULL){
root->right->next=root->next->left;
}
connect(root->left);
connect(root->right);
return root;
}
力扣------ 填充每个节点的下一个右侧节点指针
最新推荐文章于 2024-08-25 17:36:33 发布