9-line fast c++ without recursion
class Solution {\n    public:\n        void connect(TreeLinkNode *root) {\n            while (root) {\n                TreeLinkNode *a = root;\n                
    class Solution {\n    public:\n        void connect(TreeLinkNode *root) {\n            while (root) {\n                TreeLinkNode *a = root;\n                while (a) {\n                    if (a->left) {\n                        a->left->next = a->right;\n                        if (a->next)\n                            a->right->next = a->next->left;\n                    }\n                    a=a->next;\n                }\n                root=root->left;\n            }\n        }\n    };
[]