My unsorted array is
string[] a = new string[] { "10", "22", "9", "33", "21", "50", "41", "60", "80" };
In this array, 10,22,33,50,60,80
are in ascending order,
so the output must be 6
.
In general, I want the longest possible length of an ascending list made from elements of the array and starting with the first element.
I have tried this :
string[] a = new string[] { "10", "22", "9", "33", "21", "50", "41", "60", "80" };
List<int> res = new List<int>();
int arrLength = a.Length;
int i = 0;
int prev;
while (i < arrLength)
{
if (i < arrLength)
{
res.Add(Convert.ToInt32(a[i]));
prev = Convert.ToInt32(a[i]);
while (Convert.ToInt32(a[++i]) < prev) { }
}
}
int asdf = res.Count;
but did not succeed.