- 116 populating next right pointe
- LeetCode #116 #117 2018-08-07
- 117. Populating Next Right Point
- 117. Populating Next Right Point
- [Leetcode] 86. Populating Next R
- 116. Populating Next Right Point
- 116. Populating Next Right Point
- 116. Populating Next Right Point
- 116. Populating Next Right Point
- 116. Populating Next Right Point
void dfs(struct TreeLinkNode *parent){
if(parent->left == NULL || parent->right == NULL)
return;
parent->left->next = parent->right;
if(parent->next != NULL)
parent->right->next = parent->next->left;
else
parent->right->next = NULL;
dfs(parent->left);
dfs(parent->right);
}
void connect(struct TreeLinkNode *root) {
if(root == NULL)
return;
root->next = NULL;//1th
dfs(root);
}
网友评论