PIXELBANKv8.2.1
Menu

Merge Two Sorted Lists

Merge two sorted lists into one sorted list. Output as space-separated values.

Example:

Input:
1,2,4
1,3,4
Output:
1 1 2 3 4 4
Reasoning:
  • The problem starts with two sorted lists: [1, 2, 4] and [1, 3, 4].
  • The lists are merged by comparing elements from each list and adding the smaller one to the result list, resulting in a single sorted list: [1, 1, 2, 3, 4, 4].
  • The merged list is then output as space-separated values, giving the final output: 1 1 2 3 4 4.
  • No further calculations are needed, as the problem only requires a simple merge and sort operation.

Constraints:

  • 0 <= number of nodes <= 50
  • -100 <= Node.val <= 100
Editor

Test Results

0/0
Run code to see test results.