Solution Review: Finding Minimum Value in an Array
This review provides a detailed analysis to solve the "Finding Minimum Value in an Array" challenge.
We'll cover the following...
Solution #
Press + to interact
namespace chapter_2{class Solution{// Find Minimum Value in an Arraystatic int findMinimum(int []arr, int size){int minimum = arr[0];//At every index compare its value with the minimum and if it is less//then make that index value the new minimum value”for (int i = 0; i < size; i++){if (arr[i] < minimum){minimum = arr[i];}}return minimum;}static void Main(string[] args){int size = 4;int []arr = { 9, 2, 3, 6 };Console.Write("Array : ");for (int i = 0; i < size; i++)Console.Write(arr[i] + " ");Console.WriteLine("");int min = findMinimum(arr, size);Console.WriteLine("Minimum in the Array: " + min );return ;}}}
Explanation
Start with the first element (which is 9 ...