void Solution::connect(TreeLinkNode* A) {
queue<TreeLinkNode *> q; if(A==NULL) return ; q.push(A); q.push(NULL); while(!q.empty() && q.front()!=NULL) { while(q.front()!=NULL) { TreeLinkNode *front=q.front(); q.pop(); front->next=q.front(); if(front->left) q.push(front->left); if(front->right) q.push(front->right); } q.pop(); q.push(NULL); } return ;
}
5 min easy to understand straight forward
nilesh_rathi
#1