Class Solution

java.lang.Object
g0001_0100.s0021_merge_two_sorted_lists.Solution

public class Solution extends Object
21 - Merge Two Sorted Lists.<p>Easy</p> <p>Merge two sorted linked lists and return it as a <strong>sorted</strong> list. The list should be made by splicing together the nodes of the first two lists.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/10/03/merge_ex1.jpg" alt="" /></p> <p><strong>Input:</strong> l1 = [1,2,4], l2 = [1,3,4]</p> <p><strong>Output:</strong> [1,1,2,3,4,4]</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> l1 = [], l2 = []</p> <p><strong>Output:</strong> []</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> l1 = [], l2 = [0]</p> <p><strong>Output:</strong> [0]</p> <p><strong>Constraints:</strong></p> <ul> <li>The number of nodes in both lists is in the range <code>[0, 50]</code>.</li> <li><code>-100 <= Node.val <= 100</code></li> <li>Both <code>l1</code> and <code>l2</code> are sorted in <strong>non-decreasing</strong> order.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details