leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1669.cpp (406B)
0 class Solution { 1 public: 2 ListNode *mergeInBetween(ListNode *list1, int a, int b, ListNode *list2) { 3 ListNode *ap, *bp; 4 a--; 5 for (ap = list1; a; a--, b--) 6 ap = ap->next; 7 for (bp = ap; b; b--) 8 bp = bp->next; 9 ap->next = list2; 10 while (ap->next) 11 ap = ap->next; 12 ap->next = bp->next; 13 return list1; 14 } 15 };