 # QM6B editorial

Practice

Contest

Author: Chandan Boruah

Tester: Chandan Boruah

Editorialist: Chandan Boruah

EASY

Implementation

### PROBLEM:

Given an array of integers find the minimum of the maximum of all the contiguous subarrays of given length k.

### QUICK EXPLANATION:

Use nested iteration to find the maximums of the various subarrays and then print the minimum of them.

### EXPLANATION:

Iterate over the array and then find the maximum of the subarrays of length k formed from the current index of the outer loop. Then have another variable to store the value of all those maximums. Please refer code below.

Solution in CS:

``````using System;
class some
{
public static void Main()
{
for(int i=0;i<t;i++)
{
int n=int.Parse(kk);
int k=int.Parse(kk);
int[]arr=new int[n];
for(int j=0;j<n;j++)
{
arr[j]=int.Parse(kk[j]);
}
int min=int.MaxValue;
for(int j=0;j<=n-k;j++)
{
int max=0;
for(int l=j,tt=0;tt<k;tt++)
{
max=Math.Max(arr[l+tt],max);
}
min=Math.Min(max,min);
}
Console.WriteLine(min);
}
}
}
``````

Note: This problem has bug in constraints (the intended solution doesn’t work for such large constraints), due to my inadequte testing. Will try to host a better contest next time.