430. Flatten a Multilevel Doubly Linked List most easiest sol c++
\nNode* flatten(Node* head) {\n        if(!head) return head;\n        if(!head->next and !head->child)\n            return head;\n        Node *p=head;\n      
```\nNode* flatten(Node* head) {\n        if(!head) return head;\n        if(!head->next and !head->child)\n            return head;\n        Node *p=head;\n        while(p)\n        {\n            if(p->child)\n            {\n                Node *r=p->child,*q=p->next;\n                p->next=r;\n                r->prev=p;\n                while(r->next)\n                    r=r->next;\n                if(q) q->prev=r;\n                r->next=q;\n                p->child=NULL;\n                p=p->next;\n            }\n            else\n                p=p->next;\n        }\n        return head;\n    }\n\t```\n\t\n\tPlease Give an upvote if you like it
[]