C++ code with Proper explanation & Diagram
\n\n\nHere is full explanation of the code i think you guys like these and plz upvote this !\n\nclass Solution {\npublic:\n    ListNode getmid(ListNode &head)\n
![image](https://assets.leetcode.com/users/images/9b3f7f91-f7fd-4046-832e-a9967a3cec55_1666537832.3092754.png)\n\n\nHere is full explanation of the code i think you guys like these and plz upvote this !\n\nclass Solution {\npublic:\n    ListNode* getmid(ListNode* &head)\n    {\n        ListNode* slow = head;\n        ListNode* fast = head;\n        while(fast  != NULL && fast -> next != NULL)\n        {\n            slow = slow -> next;\n            fast = fast -> next -> next;\n        }\n        return slow;\n    }\n    ListNode* reverse(ListNode* head)\n    {\n        ListNode* prev = NULL;\n        ListNode* curr = head;\n        ListNode* forward = NULL;\n        while(curr  != NULL)\n        {\n            forward = curr -> next;\n            curr -> next = prev;\n            prev = curr;\n            curr = forward;\n        }\n        return prev;\n    }\n    void reorderList(ListNode* head) {\n        if(head == NULL || head -> next == NULL)return;\n        // find the mid of the linked list\n        ListNode* mid = getmid(head); \n        ListNode* l1 = head;\n        ListNode* l2 = (mid -> next);\n        mid -> next = NULL;\n        l2 = reverse(l2);\n        \n        while( l2 != NULL)\n        {\n            ListNode* f1 =l1 -> next;\n        ListNode* f2 = l2 -> next;\n            l1 -> next = l2;\n            l2 -> next = f1;\n            l1 = f1;\n            l2 = f2;\n            \n        }\n    }\n};
['C']