java.lang.Object
g1601_1700.s1669_merge_in_between_linked_lists.Solution

public class Solution extends Object
1669 - Merge In Between Linked Lists.<p>Medium</p> <p>You are given two linked lists: <code>list1</code> and <code>list2</code> of sizes <code>n</code> and <code>m</code> respectively.</p> <p>Remove <code>list1</code>&rsquo;s nodes from the <code>a<sup>th</sup></code> node to the <code>b<sup>th</sup></code> node, and put <code>list2</code> in their place.</p> <p>The blue edges and nodes in the following figure indicate the result:</p> <p><img src="https://assets.leetcode.com/uploads/2020/11/05/fig1.png" alt="" /></p> <p><em>Build the result list and return its head.</em></p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/11/05/merge_linked_list_ex1.png" alt="" /></p> <p><strong>Input:</strong> list1 = [0,1,2,3,4,5], a = 3, b = 4, list2 = [1000000,1000001,1000002]</p> <p><strong>Output:</strong> [0,1,2,1000000,1000001,1000002,5]</p> <p><strong>Explanation:</strong> We remove the nodes 3 and 4 and put the entire list2 in their place.</p> <p>The blue edges and nodes in the above figure indicate the result.</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/11/05/merge_linked_list_ex2.png" alt="" /></p> <p><strong>Input:</strong> list1 = [0,1,2,3,4,5,6], a = 2, b = 5, list2 = [1000000,1000001,1000002,1000003,1000004]</p> <p><strong>Output:</strong> [0,1,1000000,1000001,1000002,1000003,1000004,6]</p> <p><strong>Explanation:</strong> The blue edges and nodes in the above figure indicate the result.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>3 <= list1.length <= 10<sup>4</sup></code></li> <li><code>1 <= a <= b < list1.length - 1</code></li> <li><code>1 <= list2.length <= 10<sup>4</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details