Merge In Between Linked Lists Problem
Merge In Between Linked Lists Problem — ExecCode Easy DSA Practice
Solve the Merge In Between Linked Lists problem on ExecCode. Free online easy DSA practice in Linked List. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given two linked lists: list1 and list2 of sizes n and m respectively. Your task is to build the result list and return its head. Remove list1's nodes from the a^th node to the b^th node, and put list2 in their place. The blue edges and nodes in the following figure indicate the result:.
Examples
Input {"list1": [0, 1, 2, 3, 4], "list2": [100, 101, 102], "a": 1, "b": 3}; Output 0 100 101 102 4. Input {"list1": [0, 1, 2, 3, 4], "list2": [5, 6], "a": 0, "b": 4}; Output 5 6. Input {"list1": [0, 1, 2], "list2": [3, 4, 5, 6], "a": 0, "b": 1}; Output 3 4 5 6 2
Constraints
3 <= list1.length <= 10^4 1 <= a <= b < list1.length - 1 1 <= list2.length <= 10^4
Practice Merge In Between Linked Lists free on ExecCode. Browse DSA problems, topic map, and placement guides.