Video solution | Intuition and Approach Explained in detail | C++ | Recursion
Video solution \n Describe your first thoughts on how to solve this problem. \n\nhey everyone, i have made video playlist for Recursion where i explain intuitio
# Video solution \n<!-- Describe your first thoughts on how to solve this problem. -->\n\nhey everyone, i have made video playlist for Recursion where i explain intuition behind it, this video solution is part of my playlist.\nLink for video:\nhttps://youtu.be/bCiIQSZSTUc\n\n\nLink for playlist: https://www.youtube.com/playlist?list=PLICVjZ3X1AcbI-9LyJ6ss-gB3bNRTQrll\n# Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n\n   // L1->L2->L3->......Ln/2->.....Ln-2->Ln-1->Ln\n    // L1->Ln->L2->L3->L4......->Ln-1->null\n   \n    void reorderList(ListNode* head) {\n        //BC\n        if(head==NULL || head->next==NULL || head->next->next==NULL){\n            return;\n        \n        \n        }\n\n        //task\n        ListNode* second_last= head;\n        while(second_last->next->next){\n            second_last=second_last->next;\n        }\n        second_last->next->next=head->next;\n        head->next=second_last->next;\n        second_last->next=NULL;\n\n        //rr\n        reorderList(head->next->next);\n       \n\n    }\n};\n```
['C++']