Leetcode Problem 1669. Merge In Between Linked Lists

1669. Merge In Between Linked Lists

Leetcode Solutions

Iterative Approach to Merge Linked Lists

  1. Initialize two pointers, prev and curr, to traverse list1.\n2. Move curr to the ath node and prev to the node just before it.\n3. Continue moving curr until it reaches the node just after the bth node.\n4. Connect prev.next to the head of list2.\n5. Traverse to the end of list2 and connect its last node's next to curr.\n6. Return the head of the modified list1.
UML Thumbnail

Recursive Approach to Merge Linked Lists

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...