Program to find the maximum (or minimum) element of an array

Kapil Patel
Jul 6, 2021

Solution passes the test case but may not be most efficient

I will keep updating this with better solution.

Solution using C#.

using System;public class Codemirror{
static public void Main (){
//Code

int[] arr = {11, 12, 5, 9, 16, 56, 8};
int max = 0;
for(int i = 0; i < arr.Length; i++)
{
if(i==0)
{
max = arr[i];
}

if(max < arr[i] )
{
max = arr[i];
}
}
Console.WriteLine("Maximum element is: " + max);

}
}

This post is a first part of DSA RoadMap by The Code Skool

Youtube video:

https://www.youtube.com/watch?v=WjYdkHzcGhc&list=PL6ZXPAW2GSTuO4m6wCITtyVobnD1O1dkj

GeeksForGeeks top 50 array coding problems

https://www.geeksforgeeks.org/top-50-array-coding-problems-for-interviews/

Item 1 from above top 50 array problems

https://www.geeksforgeeks.org/check-if-a-key-is-present-in-every-segment-of-size-k-in-an-array/

--

--

Kapil Patel

Software engineer | loves working in a startup like environment