0ms simple 100% faster using recursion in java
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:\nO(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 {\n    public int val;\n    public Node prev;\n    public Node next;\n    public Node child;\n};\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                \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    \n    public Node findTail(Node child){\n        while(child.next != null){\n            child=child.next;\n        }\n        return child;\n    }\n}\n```
['Recursion', 'Java']