class Solution {

public:

```
void connect(TreeLinkNode *root) {
if (root && root->left) {
root->left->next = root->right;
TreeLinkNode *temp;
temp = root->left;
while (temp->right) {
temp->right->next = temp->next->left;
temp = temp->right;
}
connect(root->left);
connect(root->right);
}
}
```

};