Medium csharp

Merge sort [5, 4, 3, 2, 1] #49

Problem

Sort [5, 4, 3, 2, 1] ascending; print comma-separated.

Hints
  • Merge sort O(n²) or O(n log n)

Your solution

TestStatusDetails
Ready — edit the code above and click Run or Submit.

Solution

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] a = { 5, 4, 3, 2, 1 };
        Array.Sort(a);
        Console.WriteLine(string.Join(",", a));
    }
}

Try solving on your own first, then reveal the official answer.

Explanation

Merge sort — implement manually in interviews; Array.Sort for verification.

Discussion

0

Sign in to join the discussion.

No discussions yet — ask the first question!

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details