Hi,
What you have done so far ? try something yourself and come with some issue/problem. I am posting here the solution but i will also give you another question and expecting to resolve by you.
Solution for your question :
class calculate
{
int startIndex = 0;
int count = 3;
List<int[]> myResult = new List<int[]>();
public new List<int[]> MaxMinFinder(int[] abc)
{
int[] value1 = new int[2];
value1[0] = abc.Skip(startIndex).Take(count).Max();
value1[1] = abc.Skip(startIndex).Take(count).Min();
myResult.Add(value1);
startIndex += count;
if (startIndex <= abc.Length)
{
MaxMinFinder(abc);
}
return myResult;
}
}
You can use this function to get List<int[]>(your expected result).
Now whats your homework is,
- Make above class generalize, i do not want any fix value. in above code you can see
count = 3 is fix. make it generalize to use anywhere.
Hope you can do this, even this problem is very simpler then yours,
Best luck
Thanks
-Amit Gajjar