So I was going through different sorting algorithms. But almost all the sorting algorithms require 2 loops to sort the array. The time complexity of Bubble sort & Insert
public int find2ndLargest() { int[] arr = {1,3,14,25,7,20,11,30}; int temp; // sort array for (int i=0;iarr[i+1]) { temp = arr[i]; arr[i]=arr[i+1]; arr[i+1]=temp; i=0; } } return arr[arr.length-2]; }