Simple Clean & Clear
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/*\n// Definition for a Node.\nclass Node {\npublic:\n    int val;\n    Node* prev;\n    Node* next;\n    Node* child;\n};\n*/\n\nclass Solution {\npublic:\n    Node* flatten(Node* head) {\n        Node* temp=head;\n        while(temp){\n            if(temp->child){\n                Node* fake=temp->child;\n                while(fake->next){\n                    fake=fake->next;\n                }\n                fake->next=temp->next;\n                if(temp->next){\n                    temp->next->prev=fake;\n                }\n                temp->child->prev=temp;\n                temp->next=temp->child;\n                temp->child=NULL;\n            }\n            else{\n                temp=temp->next;\n            }\n        }\n        return head;\n    }\n};\n```
['C++']