Merge In Between Linked Lists LeetCode solution in JavaScript
1var mergeInBetween = function (list1, a, b, list2) {2let start = list1;3let end = list1;45for (let i = 0; i <= b && start != null && end != null; i++) {6if (i < a - 1) start = start.next;7if (i <= b) end = end.next;8}910let tail = list2;1112while (tail.next != null) {13tail = tail.next;14}1516start.next = list2;17tail.next = end;1819return list1;20};