C++ | 100% Faster and 100% Efficient | Most Efficient | Linear Approach |
Code -\n\n\nclass Solution {\npublic:\n    ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n        ListNode *slow = list1, *fast = l
**Code** -\n\n```\nclass Solution {\npublic:\n    ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n        ListNode *slow = list1, *fast = list1, *temp = list2;\n        while(--a){\n            slow = slow -> next;\n        }\n        b += 2;\n        while(--b){\n            fast = fast -> next;\n        }\n        while(list2 -> next != nullptr){\n            list2 = list2 -> next;\n        }\n        \n        slow -> next = temp;\n        list2 -> next = fast;\n        return list1;\n    }\n};\n```\n\n**Result**\n\n**Runtime**: **260 ms**, faster than **100.00%** of C++ online submissions for Merge In Between Linked Lists.\n**Memory Usage**: **94.5 MB**, less than **100.00%** of C++ online submissions for Merge In Between Linked Lists.
['Linked List', 'C']