Easy csharp

DS — find min in array #52

Problem

Print minimum of [6, 5, 4, 3, 2, 1].

Hints
  • Track running minimum

Your solution

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

Solution

using System;

class Program
{
    static void Main()
    {
        int[] a = { 6, 5, 4, 3, 2, 1 };
        int min = a[0];
        foreach (var x in a) if (x < min) min = x;
        Console.WriteLine(min);
    }
}

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

Explanation

Linear scan for min/max.

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