Java solution
\nclass Solution {\n    public Node flatten(Node head) {\n        Node p = head;\n        while(p != null){\n            if(p.child != null){\n                N
```\nclass Solution {\n    public Node flatten(Node head) {\n        Node p = head;\n        while(p != null){\n            if(p.child != null){\n                Node tmp = p.child;\n                while(tmp.next != null)\n                    tmp = tmp.next;\n                tmp.next = p.next;\n                if(p.next != null)\n                    p.next.prev = tmp;\n                p.next = p.child;\n                p.child.prev = p;\n                p.child = null;\n            }\n            p = p.next;\n        }\n        return head;\n    }\n}\n```\n\nRuntime: 0 ms, faster than 100.00% of Java online submissions for Flatten a Multilevel Doubly Linked List.\nMemory Usage: 37.2 MB, less than 96.89% of Java online submissions for Flatten a Multilevel Doubly Linked List.
['Java']