Home > Mobile >  i want to Merge a sorted lists in c#
i want to Merge a sorted lists in c#

Time:08-13

Is there any way given an array of sorted linked lists I want to merge all lists into one sorted linked link like below exzmple :

For example:

Input:  lists =
                [
                    1 -> 2,
                    2 -> 3,
                    1 -> 4
                ]

CodePudding user response:

Use the below code to merge all lists into one sorted linked link

public class ListNode
{
    public int Value;
    public ListNode Next;

    public ListNode(int x)
    {
        Value = x;
    }
}
*/
public sealed class Solution
{
    public ListNode MergeSortedLists(ListNode[] lists)
    {
    }
}
  •  Tags:  
  • c#
  • Related