C++ Straightforward O(N)
See my latest update in repo LeetCode\n\n## Solution 1.\n\nFind the following pointers:\n p where p->next points to ath node.\n q where p points to bth node.\n\
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1.\n\nFind the following pointers:\n* `p` where `p->next` points to `a`th node.\n* `q` where `p` points to `b`th node.\n\nThen we can stitch them together by assigning:\n* `B` to `p->next`\n* `q->next` to the `next` pointer of `B`\'s tail node.\n\n```cpp\n// OJ: https://leetcode.com/contest/biweekly-contest-40/problems/merge-in-between-linked-lists/\n// Author: github.com/lzl124631x\n// Time: O(N)\n// Space: O(1)\nclass Solution {\npublic:\n    ListNode* mergeInBetween(ListNode* A, int a, int b, ListNode* B) {\n        ListNode *q = A, *p = NULL;\n        for (int i = 0; i < b; ++i) {\n            if (i == a - 1) p = q;\n            q = q->next;\n        }\n        p->next = B;\n        while (B->next) B = B->next;\n        B->next = q->next;\n        return A;\n    }\n};\n```
[]