I have a array like {12,13,24,45,65,27,37,43,41,50,75,68}. Write a method or logic to get 3rd largest value in the array in only Single Loop is use without using sort.
Jitendra Kumar
public void GetThirdHigestNumber(){int[] array = { 12, 13, 24, 45, 65, 27, 37, 43, 41, 50, 75, 68 };var objResult = array.OrderByDescending(x => x).ToList().Take(3);int thirdHighestNumber = 0;foreach (int num in objResult){thirdHighestNumber = num;}Console.WriteLine("Third Hieghest Number : {0}", thirdHighestNumber);}
public static int thirdLargestNumber(int[] numbers){for(int i=0;i
int iCount = 0;int[] array = new int[12] { 12, 13, 24, 45, 65, 27, 37, 43, 41, 50, 75, 68 };for (int i = 0; i <= array.Length; i++){for (int j = i + 1; j < array.Length; j++){if (array[i] > array[j]){iCount = array[i];array[i] = array[j];array[j] = iCount;}}}Console.WriteLine(array[2]);
int[] arr={12,13,24,45,65,27,37,43,41,50,75,68};var q = arr.OrderByDescending(a => a).ToArray();for (int i = 0; i < q.Count(); i++ ){if (i == 2){Console.WriteLine(q[i].ToString());break;}}