💯 Beats 100% || ✅ Easy to understand & Best solution ⬆️🆙 || O(n)💥👏🔥
Please upvote if my solution and efforts helped you.\n***\n\n\n\n# Code\n\nclass Solution {\n    public Node flatten(Node head) {\n        Node curr=head;\n    
# Please upvote if my solution and efforts helped you.\n***\n![proof.png](https://assets.leetcode.com/users/images/418680c1-c4b1-4f60-af6a-8449f1cfe91a_1718644403.7132628.png)\n\n\n# Code\n```\nclass Solution {\n    public Node flatten(Node head) {\n        Node curr=head;\n        while(curr!=null){\n            if(curr.child != null){\n                Node tail = findTail(curr.child);\n                if(curr.next != null){\n                    curr.next.prev=tail;\n                }\n                tail.next = curr.next;\n                curr.next =curr.child;\n                curr.child.prev = curr;\n                curr.child =null;\n            }\n            curr = curr.next;\n        }\n        return head;\n    }\n    public Node findTail(Node child){\n        while(child.next != null){\n            child=child.next;\n        }\n        return child;\n    }\n}\n```\n![95b59d87-f0ce-4723-8fa9-f4538bdede4c_1715820685.5989218.jpeg](https://assets.leetcode.com/users/images/bd3b30d0-f646-4dac-8270-468d551c8cd4_1718644425.2220125.jpeg)\n
['Linked List', 'Doubly-Linked List', 'Java']