5 lines C++ simple solution.
class Solution {\n    public:\n        void connect(TreeLinkNode *root) {\n            if (!root) return;\n            if (root->left) root->left->next = root->
    class Solution {\n    public:\n        void connect(TreeLinkNode *root) {\n            if (!root) return;\n            if (root->left) root->left->next = root->right;\n            if (root->right && root->next) root->right->next = root->next->left;\n            connect(root->left);\n            connect(root->right);\n        }\n    };
[]