Easy to understand 4ms code
\nNode *flatten(Node *head)\n    {\n\n        Node *temp = head;\n\n        while (temp != NULL)\n        {\n            if (temp->child)\n            {\n      
```\nNode *flatten(Node *head)\n    {\n\n        Node *temp = head;\n\n        while (temp != NULL)\n        {\n            if (temp->child)\n            {\n                Node *node_child = temp->child;\n                if (temp->next == NULL)\n                {\n                    temp->next = node_child;\n                    node_child->prev = temp;\n                    temp->child = NULL;\n                    continue;\n                }\n                Node *next_node= temp->next; // this next node pointer is required to remove infinte loop\n                \n\n                temp->next = node_child;\n                node_child->prev = temp;\n                temp->child = NULL;\n                while (node_child->next != NULL)\n                {\n                    node_child = node_child->next;\n                }\n                node_child->next = next_node;\n                next_node->prev = node_child;\n            }\n\n            temp = temp->next;\n        }\n        return head;\n    }\n\t```
['C']