Best code || easy to understand || must see
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```\nclass Solution {\npublic:\n    Node* flatten(Node* head) {\n        Node*temp=head;\n        while(temp){\n            Node*a=temp->next;\n            if(temp->child!=NULL){\n                Node*c=temp->child;\n                temp->child=NULL;\n                c=flatten(c); // recursion\n                temp->next=c;\n                c->prev=temp;\n                while(c->next!=NULL) c=c->next;\n                c->next=a;\n                if(a!=NULL) a->prev=c;\n            }\n            temp=a;\n        }\n        \n        return head;\n    }\n};\n```
['C++']