1669. Merge In Between Linked Lists

https://leetcode.com/problems/merge-in-between-linked-lists

Description

You are given two linked lists: list1 and list2 of sizes n and m respectively.

Remove list1's nodes from the ath node to the bth node, and put list2 in their place.

The blue edges and nodes in the following figure incidate the result:

Build the result list and return its head.

Example 1:

Example 2:

Constraints:

  • 3 <= list1.length <= 104

  • 1 <= a <= b < list1.length - 1

  • 1 <= list2.length <= 104

ac

Last updated

Was this helpful?