Here is the test case which fails

Input: {3,9,20,#,#,15,7}

Output: {3,#,9,20,#,15,#}

Expected: {3,#,9,20,#,15,7,#}

I can not understand expected output format. plz help

```
void connect(TreeLinkNode *root) {
if(!root) return;
TreeLinkNode *p=root,*q;
while(p->left)
{
q=p->left;
while(p)
{
if(p->left && p->right) p->left->next=p->right;
if(p->next)
{
if(p->right)
{
if(p->next->left) p->right->next=p->next->left;
else p->right->next=p->next->right;
}
else if (p->left && !p->right)
{
if(p->next->left) p->left->next=p->next->left;
else p->left->next=p->next->right;
}
}
p=p->next;
}
p=q;
}
}
```