struggling struggling - 1 year ago 74
C# Question

How to create Monolithic lists from array in increasing order (sub-Lists)

I have to create a monolithic list from an array in increasing order in c#. I was given

[1 2 4 7 5 6 3 2]
as test input whose test output is
[[1 2 4 7] [5 6] [3] [2]]
. The thing is i am not at all able to understand what question is and what it is asking me to do so that i start.

Could some one please me what is monolithic mean in current scenario of array ? and how these 4 array output produced from the input array ?

Edit I have understood how these sublists are created upon input array, they are created when
. But how to code such dynamic sublists inside lists ?

Answer Source

This is the old fashioned way:

List<int> sublist=new List<int>();
int last=Int32.MinValue;
List<int[]> list=new List<int[]>();
foreach(var i in input)
     sublist=new List<int>();
var answer=list.ToArray();

The newer way would be to return an IEnumerable<IEnumerable<int>> that is traversed only when enumerated, and is much better, but I'll leave that as an exercise for you or someone else to do.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download